first
This commit is contained in:
165
ent/ogent/oas_cfg_gen.go
Normal file
165
ent/ogent/oas_cfg_gen.go
Normal file
@@ -0,0 +1,165 @@
|
||||
// Code generated by ogen, DO NOT EDIT.
|
||||
|
||||
package ogent
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"math/big"
|
||||
"math/bits"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
"github.com/go-faster/jx"
|
||||
"github.com/google/uuid"
|
||||
"github.com/ogen-go/ogen/conv"
|
||||
ht "github.com/ogen-go/ogen/http"
|
||||
"github.com/ogen-go/ogen/json"
|
||||
"github.com/ogen-go/ogen/otelogen"
|
||||
"github.com/ogen-go/ogen/uri"
|
||||
"github.com/ogen-go/ogen/validate"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
// No-op definition for keeping imports.
|
||||
var (
|
||||
_ = context.Background()
|
||||
_ = fmt.Stringer(nil)
|
||||
_ = strings.Builder{}
|
||||
_ = errors.Is
|
||||
_ = sort.Ints
|
||||
_ = http.MethodGet
|
||||
_ = io.Copy
|
||||
_ = json.Marshal
|
||||
_ = bytes.NewReader
|
||||
_ = strconv.ParseInt
|
||||
_ = time.Time{}
|
||||
_ = conv.ToInt32
|
||||
_ = uuid.UUID{}
|
||||
_ = uri.PathEncoder{}
|
||||
_ = url.URL{}
|
||||
_ = math.Mod
|
||||
_ = bits.LeadingZeros64
|
||||
_ = big.Rat{}
|
||||
_ = validate.Int{}
|
||||
_ = ht.NewRequest
|
||||
_ = net.IP{}
|
||||
_ = otelogen.Version
|
||||
_ = attribute.KeyValue{}
|
||||
_ = trace.TraceIDFromHex
|
||||
_ = otel.GetTracerProvider
|
||||
_ = metric.NewNoopMeterProvider
|
||||
_ = regexp.MustCompile
|
||||
_ = jx.Null
|
||||
_ = sync.Pool{}
|
||||
_ = codes.Unset
|
||||
)
|
||||
|
||||
// bufPool is pool of bytes.Buffer for encoding and decoding.
|
||||
var bufPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
return new(bytes.Buffer)
|
||||
},
|
||||
}
|
||||
|
||||
// getBuf returns buffer from pool.
|
||||
func getBuf() *bytes.Buffer {
|
||||
return bufPool.Get().(*bytes.Buffer)
|
||||
}
|
||||
|
||||
// putBuf puts buffer to pool.
|
||||
func putBuf(b *bytes.Buffer) {
|
||||
b.Reset()
|
||||
bufPool.Put(b)
|
||||
}
|
||||
|
||||
type config struct {
|
||||
TracerProvider trace.TracerProvider
|
||||
Tracer trace.Tracer
|
||||
MeterProvider metric.MeterProvider
|
||||
Meter metric.Meter
|
||||
Client ht.Client
|
||||
NotFound http.HandlerFunc
|
||||
}
|
||||
|
||||
func newConfig(opts ...Option) config {
|
||||
cfg := config{
|
||||
TracerProvider: otel.GetTracerProvider(),
|
||||
MeterProvider: metric.NewNoopMeterProvider(),
|
||||
Client: http.DefaultClient,
|
||||
NotFound: http.NotFound,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt.apply(&cfg)
|
||||
}
|
||||
cfg.Tracer = cfg.TracerProvider.Tracer(otelogen.Name,
|
||||
trace.WithInstrumentationVersion(otelogen.SemVersion()),
|
||||
)
|
||||
cfg.Meter = cfg.MeterProvider.Meter(otelogen.Name)
|
||||
return cfg
|
||||
}
|
||||
|
||||
type Option interface {
|
||||
apply(*config)
|
||||
}
|
||||
|
||||
type optionFunc func(*config)
|
||||
|
||||
func (o optionFunc) apply(c *config) {
|
||||
o(c)
|
||||
}
|
||||
|
||||
// WithTracerProvider specifies a tracer provider to use for creating a tracer.
|
||||
//
|
||||
// If none is specified, the global provider is used.
|
||||
func WithTracerProvider(provider trace.TracerProvider) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
if provider != nil {
|
||||
cfg.TracerProvider = provider
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// WithMeterProvider specifies a meter provider to use for creating a meter.
|
||||
//
|
||||
// If none is specified, the metric.NewNoopMeterProvider is used.
|
||||
func WithMeterProvider(provider metric.MeterProvider) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
if provider != nil {
|
||||
cfg.MeterProvider = provider
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// WithClient specifies http client to use.
|
||||
func WithClient(client ht.Client) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
if client != nil {
|
||||
cfg.Client = client
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// WithNotFound specifies http handler to use.
|
||||
func WithNotFound(notFound http.HandlerFunc) Option {
|
||||
return optionFunc(func(cfg *config) {
|
||||
if notFound != nil {
|
||||
cfg.NotFound = notFound
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user