Documentation ¶
Index ¶
Constants ¶
const ( DefaultBackoffMinimum = 10 * time.Second DefaultBackoffMaximum = 20 * time.Minute DefaultBackoffFactor = 1.2 DefaultBackoffJitter = 0.2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter is a rate limiter and has an exponential backoff implementation in the event of too many errors which further reduces the rate of operations.
In the context of taskscaler, it's used when scaling up instances, and caps how many instances can be requested per second. It has the ability to burst, so for example, if you allow 100 requests per second, but have not requested anything for 1 second, you'll immediately be able to request 100.
If taskscaler tells the limiter that too many errors have occurred, no scaling can happen until after an exponential backoff delay.
func (*Limiter) Delay ¶
Delay returns the current delay and whether the delay has been adjusted since the last call.
func (*Limiter) Failure ¶
func (l *Limiter) Failure()
Failure registers a failure. Each failure exponentially increases the delay before N returns >0.
func (*Limiter) LimitBurst ¶
LimitBurst returns the limit and burst settings.
func (*Limiter) N ¶
N returns rate limited n, this can be 0 if there's no bucket capacity or if we're delayed due to exponential backoff.
func (*Limiter) SetBackoff ¶
SetBackoff sets a custom backoff, factor and jitter.