Documentation ¶
Overview ¶
Package middleware provides common middleware and decorators for WebPA and XMiDT servers
Index ¶
Constants ¶
const DefaultTimeout = 30 * time.Second
Variables ¶
This section is empty.
Functions ¶
func Busy ¶
func Busy(maxClients int64, busyError error) endpoint.Middleware
Busy produces a middleware that returns an error if the maximum number of clients is reached. If busyError is specified, that is returned. Otherwise, a default error is returned.
If maxClients is nonpositive, this factory function panics
func Concurrent ¶
func Concurrent(concurrency int, timeoutError error) endpoint.Middleware
Concurrent produces a middleware that allows only a set number of concurrent calls via a semaphore implemented as a buffered channel. The context is used for cancellation, and if the context is cancelled then timeoutError is returned if it is not nil, ctx.Err() otherwise.
func Logging ¶
Logging is a go-kit middleware that inserts any associated logger from requests into the context. Requests that do not provide a Logger() log.Logger method are simply ignored.
This middleware is primarily useful because go-kit does not allow you to alter the context when requests are decoded. That means that any contextual logger created when the request was decoded isn't visible in the context, unless something like this middleware is used.
Types ¶
This section is empty.