Documentation ¶
Index ¶
- Constants
- func EstimatedWaitTime(limiter Limiter, average time.Duration) time.Duration
- func NewMockLimiter(stubRun bool) *mockLimiter
- func NewMockThrottler(run bool) *mockThrottler
- func ThrottlerMiddleware(th Throttler) func(next http.Handler) http.Handler
- type ErrThrottled
- type Limiter
- func NewGauge(gauge gaugor, tags statsd.Tags) Limiter
- func NewLimiter(concurrency uint) Limiter
- func NewLimiterWithGauge(concurrency uint, gauge gaugor, tags statsd.Tags) Limiter
- func NewLimiterWithSampledGauge(concurrency uint, gauge gaugor, sampling int32, tags statsd.Tags) Limiter
- func NewSampledGauge(gauge gaugor, sampling int32, tags statsd.Tags) Limiter
- type Throttler
Constants ¶
View Source
const ( NoLimit uint = 0 AlwaysRecord int32 = 0 )
Variables ¶
This section is empty.
Functions ¶
func EstimatedWaitTime ¶
func NewMockLimiter ¶
func NewMockLimiter(stubRun bool) *mockLimiter
func NewMockThrottler ¶
func NewMockThrottler(run bool) *mockThrottler
Types ¶
type ErrThrottled ¶
func (*ErrThrottled) Error ¶
func (t *ErrThrottled) Error() string
type Limiter ¶
type Limiter interface { // Run executes a function, making sure at most a certain number of calls are executing simultaneously // It does _not_ start a goroutine, the function will be executing on the caller's stack. // If the context is canceled while waiting, it will abort. Run(ctx context.Context, fn func() error) error // Waiting returns a (racy) counter of how many Run calls are currently waiting to run. Waiting() int32 // Running returns a (racy) counter of how many Run calls are currently executing their function. Running() int32 MaxConcurrency() uint }
func NewLimiter ¶
func NewLimiterWithGauge ¶
Click to show internal directories.
Click to hide internal directories.