Documentation
¶
Overview ¶
Package backoff provides exponential back-off with jitter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backoff ¶
type Backoff struct {
// Base is the initial delay returned on the first call to Next.
Base time.Duration
// Multiplier is applied on each successive attempt (e.g. 2.0 doubles).
Multiplier float64
// MaxDelay caps the delay before jitter is applied.
MaxDelay time.Duration
// Jitter is the fraction of the delay applied as a symmetric random offset,
// e.g. 0.2 means ±20%.
Jitter float64
// contains filtered or unexported fields
}
Backoff computes exponential back-off delays with optional jitter. The zero value is not useful; use a struct literal with explicit fields.
b := &backoff.Backoff{
Base: time.Second,
Multiplier: 2,
MaxDelay: 60 * time.Second,
Jitter: 0.2,
}
Click to show internal directories.
Click to hide internal directories.