Documentation
¶
Index ¶
- Constants
- Variables
- func EndpointFromContext(ctx context.Context) (*config.Endpoint, bool)
- func InitMetaStreamContext(opts *RequestOptions, value *MetaStreamContext)
- 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
- func WrapReadCloserBody(rc io.ReadCloser, tag string, ctxValue *MetaStreamContext) *readCloserBody
- func WrapReadWriteCloserBody(rwc io.ReadWriteCloser, ctxValue *MetaStreamContext) *readWriteCloserBody
- type Factory
- type FactoryV2
- type MetaStreamChunk
- type MetaStreamContext
- type MetaStreamContextKey
- type MetricsLabels
- type Middleware
- type MiddlewareV2
- type Registry
- type RequestOptions
- type RequestValues
- type RoundTripperFunc
- type StreamBody
Constants ¶
const ( TagRequest = "request" TagResponse = "response" )
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 InitMetaStreamContext ¶
func InitMetaStreamContext(opts *RequestOptions, value *MetaStreamContext)
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.
func WrapReadCloserBody ¶
func WrapReadCloserBody(rc io.ReadCloser, tag string, ctxValue *MetaStreamContext) *readCloserBody
func WrapReadWriteCloserBody ¶
func WrapReadWriteCloserBody(rwc io.ReadWriteCloser, ctxValue *MetaStreamContext) *readWriteCloserBody
Types ¶
type Factory ¶
type Factory func(*configv1.Middleware) (Middleware, error)
Factory is a middleware factory.
type FactoryV2 ¶
type FactoryV2 func(*configv1.Middleware) (MiddlewareV2, error)
type MetaStreamChunk ¶
type MetaStreamContext ¶
type MetaStreamContext struct {
Request *http.Request
Response *http.Response
OnResponse []func(req *http.Request, reply *http.Response)
OnFinish []func(req *http.Request, reply *http.Response)
OnChunk []func(req *http.Request, reply *http.Response, chunk *MetaStreamChunk)
// contains filtered or unexported fields
}
func GetMetaStreamContext ¶
func GetMetaStreamContext(opts *RequestOptions) (*MetaStreamContext, bool)
func (*MetaStreamContext) DoOnResponse ¶
func (s *MetaStreamContext) DoOnResponse()
func (*MetaStreamContext) RegisterBody ¶
func (s *MetaStreamContext) RegisterBody()
RegisterBody increments the count of bodies to wait for before calling OnFinish
type MetaStreamContextKey ¶
type MetaStreamContextKey struct{}
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 *configv1.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 *configv1.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.
type StreamBody ¶
type StreamBody interface {
CloseNotify() <-chan bool
}