Documentation
¶
Index ¶
- Variables
- func Handler(breaker *Breaker, next http.Handler) http.HandlerFunc
- func NewReverseProxy(target string, maxIdle, maxIdlePerHost int) *httputil.ReverseProxy
- type Breaker
- func (b *Breaker) Capacity() int
- func (b *Breaker) InFlight() int64
- func (b *Breaker) Maybe(ctx context.Context, thunk func()) error
- func (b *Breaker) QueueLength() int64
- func (b *Breaker) Reserve(_ context.Context) (func(), bool)
- func (b *Breaker) UpdateConcurrency(size int)
- func (b *Breaker) UpdateQueueLength(size int)
- type BreakerParams
- type PrometheusStatsReporter
- type RequestStats
- type RequestStatsReport
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRequestQueueFull indicates the breaker queue depth was exceeded. ErrRequestQueueFull = errors.New("pending request queue full") )
Functions ¶
func NewReverseProxy ¶
func NewReverseProxy(target string, maxIdle, maxIdlePerHost int) *httputil.ReverseProxy
NewReverseProxy creates a new cortex base reverse proxy
Types ¶
type Breaker ¶
type Breaker struct {
// contains filtered or unexported fields
}
Breaker is a component that enforces a concurrency limit on the execution of a function. It also maintains a queue of function executions in excess of the concurrency limit. Function call attempts beyond the limit of the queue are failed immediately.
func NewBreaker ¶
func NewBreaker(params BreakerParams) *Breaker
NewBreaker creates a Breaker with the desired queue depth, concurrency limit and initial capacity.
func (*Breaker) Capacity ¶
Capacity returns the number of allowed in-flight requests on this breaker.
func (*Breaker) InFlight ¶
InFlight returns the number of requests currently in flight in this breaker.
func (*Breaker) Maybe ¶
Maybe conditionally executes thunk based on the Breaker concurrency and queue parameters. If the concurrency limit and queue capacity are already consumed, Maybe returns immediately without calling thunk. If the thunk was executed, Maybe returns true, else false.
func (*Breaker) QueueLength ¶ added in v0.38.0
func (*Breaker) Reserve ¶
Reserve reserves an execution slot in the breaker, to permit richer semantics in the caller. The caller on success must execute the callback when done with work.
func (*Breaker) UpdateConcurrency ¶
UpdateConcurrency updates the maximum number of in-flight requests.
func (*Breaker) UpdateQueueLength ¶ added in v0.38.0
UpdateQueueLength updates the number of allowed requests in-queue
type BreakerParams ¶
BreakerParams defines the parameters of the breaker.
type PrometheusStatsReporter ¶
type PrometheusStatsReporter struct {
// contains filtered or unexported fields
}
func NewPrometheusStatsReporter ¶
func NewPrometheusStatsReporter() *PrometheusStatsReporter
func (*PrometheusStatsReporter) Report ¶
func (r *PrometheusStatsReporter) Report(stats RequestStatsReport)
func (*PrometheusStatsReporter) ServeHTTP ¶
func (r *PrometheusStatsReporter) ServeHTTP(w http.ResponseWriter, req *http.Request)
type RequestStats ¶
func (*RequestStats) Append ¶
func (s *RequestStats) Append(val int64)
func (*RequestStats) GetAllAndDelete ¶
func (s *RequestStats) GetAllAndDelete() []int64
func (*RequestStats) Report ¶
func (s *RequestStats) Report() RequestStatsReport
type RequestStatsReport ¶
type RequestStatsReport struct {
AvgInFlight float64
}