Documentation
¶
Overview ¶
Package backoff provides retry delay policies: exponential with full jitter (the default, base 1s, cap 24h), constant, and custom functions.
p := backoff.NewExponential() next := now.Add(p.Delay(job.Attempt))
Index ¶
Constants ¶
View Source
const ( DefaultBase = time.Second DefaultCap = 24 * time.Hour )
Default parameters of the exponential policy.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exponential ¶
type Exponential struct {
Base time.Duration
Cap time.Duration
// Rand returns a float in [0, 1); nil uses math/rand/v2 (goroutine-safe).
Rand func() float64
}
Exponential is min(Cap, Base*2^(attempt-1)) with full jitter: the delay is drawn uniformly from [0, ceiling).
func NewExponential ¶
func NewExponential() Exponential
NewExponential returns the default policy: base 1s, cap 24h.
Click to show internal directories.
Click to hide internal directories.