pub enum JitterPolicy {
None,
Full,
Equal,
Decorrelated,
}Expand description
Policy controlling randomization of retry delays.
Prevents synchronized retries across multiple tasks by adding controlled randomness.
§Trade-offs
- None: Predictable, but risks thundering herd
- Full: Maximum randomness, aggressive load spreading
- Equal: Balanced (recommended for most use cases)
- Decorrelated: Stateful, prevents retry correlation (requires previous delay)
Variants§
None
No jitter: use exact backoff delay.
Use when:
- Only one task retrying (no herd risk)
- Predictable timing required
- Testing/debugging
Full
Full jitter: random delay in [0, backoff_delay].
Most aggressive jitter, can significantly reduce delay. Use when maximum load spreading is needed.
Equal
Equal jitter: delay/2 + random[0, delay/2].
Balances predictability with randomness (recommended default). Preserves ~75% of the original backoff on average.
Decorrelated jitter: delay = random[base, prev_delay * 3], capped at max.
More sophisticated, considers the previous delay and grows independently.
Requires context via apply_decorrelated.
Implementations§
Source§impl JitterPolicy
impl JitterPolicy
Sourcepub fn apply(&self, delay: Duration) -> Duration
pub fn apply(&self, delay: Duration) -> Duration
Applies jitter to the given delay.
§Note
For Decorrelated, this method returns the input unchanged.
Use apply_decorrelated instead,
as it requires additional context (previous delay, base, max).
Applies decorrelated jitter with full context.
base: minimal delay (usually the initial backoff)prev: previous actual delaymax: maximum cap
§Note
If called on a non-Decorrelated policy, falls back to apply(base).
Trait Implementations§
Source§impl Clone for JitterPolicy
impl Clone for JitterPolicy
Source§fn clone(&self) -> JitterPolicy
fn clone(&self) -> JitterPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JitterPolicy
impl Debug for JitterPolicy
Source§impl Default for JitterPolicy
impl Default for JitterPolicy
Source§fn default() -> Self
fn default() -> Self
Returns JitterPolicy::None as default (backwards compatible).