Skip to main content

full_jitter

Function full_jitter 

Source
pub fn full_jitter(backoff: Duration, unit: f64) -> Duration
Expand description

Full jitter: backoff scaled by unit, a uniformly random draw from [0, 1) the caller supplies, so the wait is spread over [0, backoff) and clients that failed together do not retry in lockstep. The runtime reads no randomness of its own: pass, for example, rand::random::<f64>().

A draw at or below 0 (or not a number) waits nothing, and one at or above 1 the whole backoff; the result never exceeds backoff, and the helper never panics.