Documentation ¶
Index ¶
- Variables
- func EndpointFromContext(ctx context.Context) (*config.Endpoint, bool)
- func NewRequestContext(ctx context.Context, o *RequestOptions) context.Context
- func Register(name string, factory Factory)
- func RegisterV2(name string, factory FactoryV2)
- func RequestBackendsFromContext(ctx context.Context) ([]string, bool)
- func SelectorFiltersFromContext(ctx context.Context) ([]selector.NodeFilter, bool)
- func WithRequestBackends(ctx context.Context, backend ...string) context.Context
- func WithSelectorFitler(ctx context.Context, fn selector.NodeFilter) context.Context
- type Factory
- type FactoryV2
- type MetricsLabels
- type Middleware
- type MiddlewareV2
- type Registry
- type RequestOptions
- type RequestValues
- type RoundTripperFunc
Constants ¶
This section is empty.
Variables ¶
var EmptyMiddleware = emptyMiddleware{}
var ErrNotFound = errors.New("Middleware has not been registered")
ErrNotFound is middleware not found.
Functions ¶
func EndpointFromContext ¶
EndpointFromContext returns endpoint config from context.
func NewRequestContext ¶
func NewRequestContext(ctx context.Context, o *RequestOptions) context.Context
NewRequestContext returns a new Context that carries value.
func RegisterV2 ¶
RegisterV2 registers one v2 middleware.
func RequestBackendsFromContext ¶
RequestBackendsFromContext returns backend nodes from context.
func SelectorFiltersFromContext ¶
func SelectorFiltersFromContext(ctx context.Context) ([]selector.NodeFilter, bool)
SelectorFiltersFromContext returns selector filter from context.
func WithRequestBackends ¶
WithRequestBackends with backend nodes into context.
func WithSelectorFitler ¶
WithSelectorFitler with selector filter into context.
Types ¶
type Factory ¶
type Factory func(*config.Middleware) (Middleware, error)
Factory is a middleware factory.
type FactoryV2 ¶
type FactoryV2 func(*config.Middleware) (MiddlewareV2, error)
type MetricsLabels ¶
type MetricsLabels interface { Protocol() string Method() string Path() string Service() string BasePath() string }
func MetricsLabelsFromContext ¶
func MetricsLabelsFromContext(ctx context.Context) (MetricsLabels, bool)
func NewMetricsLabels ¶
func NewMetricsLabels(ep *config.Endpoint) MetricsLabels
type Middleware ¶
type Middleware func(http.RoundTripper) http.RoundTripper
Middleware is handler middleware.
func (Middleware) Close ¶
func (f Middleware) Close() error
func (Middleware) Process ¶
func (f Middleware) Process(in http.RoundTripper) http.RoundTripper
type MiddlewareV2 ¶
type MiddlewareV2 interface { Process(http.RoundTripper) http.RoundTripper io.Closer }
func Create ¶
func Create(cfg *config.Middleware) (MiddlewareV2, error)
Create instantiates a middleware based on `cfg`.
func NewWithCloser ¶
func NewWithCloser(process Middleware, closer io.Closer) MiddlewareV2
type Registry ¶
type Registry interface { Register(name string, factory Factory) RegisterV2(name string, factory FactoryV2) Create(cfg *config.Middleware) (MiddlewareV2, error) }
Registry is the interface for callers to get registered middleware.
type RequestOptions ¶
type RequestOptions struct { Endpoint *config.Endpoint Filters []selector.NodeFilter Backends []string Metadata map[string]string UpstreamStatusCode []int UpstreamResponseTime []float64 CurrentNode selector.Node DoneFunc selector.DoneFunc LastAttempt bool Values RequestValues }
RequestOptions is a request option.
func FromRequestContext ¶
func FromRequestContext(ctx context.Context) (*RequestOptions, bool)
FromRequestContext returns request options from context.
func NewRequestOptions ¶
func NewRequestOptions(c *config.Endpoint) *RequestOptions
NewRequestOptions new a request options with retry filter.
type RoundTripperFunc ¶
RoundTripperFunc is an adapter to allow the use of ordinary functions as HTTP RoundTripper.