Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exponential ¶
type Exponential struct { // BaseDelay is the amount of time to backoff after the first failure. BaseDelay time.Duration // Multiplier is the factor that exponentially multiplies the backoff after a retry failure. Multiplier float64 // MaxDelay is the upper bound of backoff delay. MaxDelay time.Duration }
Exponential implements the defined exponential compensation algorithm.
type Jitter ¶
type Jitter struct { // Jitter is the randomized backoff of jitter Jitter time.Duration // Rand is make random numbers for jitter Rand RandFloat64 }
Jitter implements the randomize backoff delays so that if a cluster of requests start at the same time, they won't operate in lockstep.
type Linear ¶
type Linear struct { // BaseDelay is the amount of time to backoff after. BaseDelay time.Duration // Multiplier is the factor with which to multiply backoffs after a failed retry. Multiplier float64 // MaxDelay is the upper bound of backoff delay. MaxDelay time.Duration }
Linear implements the defined linear compensation algorithm.
type RandFloat64 ¶
type RandFloat64 interface { // Float64 returns, as a float64, a pseudo-random number in [0.0,1.0). Float64() float64 }
RandFloat64 defines the methodology for jitter.
type Strategy ¶
type Strategy interface { // BackOff returns the amount of time to wait before the next retry given the number of consecutive failures. BackOff(retries uint) time.Duration }
Strategy defines the methodology for backing off after.
var DefaultConstant Strategy = &Superposition{ defaultJitter, &Constant{ Delay: 1 * time.Second, }, }
var DefaultExponential Strategy = &Superposition{ defaultJitter, &Exponential{ BaseDelay: 1 * time.Second, Multiplier: 1.6, MaxDelay: 120 * time.Second, }, }
type Superposition ¶
type Superposition []Strategy
Click to show internal directories.
Click to hide internal directories.