Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMaxConcurrent = errors.New("max concurrent requests inflight")
Functions ¶
This section is empty.
Types ¶
type Gate ¶
type Gate interface { // Start initiates a new request and waits until it's our turn to fulfill a request. Start(ctx context.Context) error // Done finishes a query. Done() }
Gate controls the maximum number of concurrently running and waiting queries.
Example of use:
g := gate.New(r, 5) if err := g.Start(ctx); err != nil { return } defer g.Done()
func New ¶
func New(reg prometheus.Registerer, maxConcurrent int) Gate
New returns an instrumented gate limiting the number of requests being executed concurrently.
The gate implementation is based on the github.com/prometheus/prometheus/util/gate package.
It can be called several times but not with the same registerer otherwise it will panic when trying to register the same metric multiple times.
func NewBlocking ¶
func NewInstrumented ¶
func NewInstrumented(reg prometheus.Registerer, maxConcurrent int, gate Gate) Gate
NewInstrumented wraps a Gate implementation with one that records max number of inflight requests, currently inflight requests, and the duration of calls to the Start method.
func NewNoop ¶
func NewNoop() Gate
NewNoop creates a Gate implementation that doesn't enforce any limit.