Documentation
¶
Overview ¶
Package backoff computes retry delays with jitter.
Jitter matters here beyond the usual load-smoothing argument: every follower in every cluster polls the same row, and an unjittered retry period makes them converge into a synchronised herd that all wake, all read, and all contend at the same instant.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backoff ¶
type Backoff struct {
// contains filtered or unexported fields
}
Backoff produces an exponentially growing, jittered delay. The zero value is not usable; construct one with New.
func New ¶
New returns a Backoff that starts at base, multiplies by factor per attempt, and is capped at max. jitter is the fraction of the computed delay that is randomly subtracted, in [0, 1]: 0.2 yields a delay in [0.8d, d].
randFloat supplies values in [0, 1) and may be nil, in which case the global source is used. Tests inject it to make delays deterministic.