#[non_exhaustive]pub enum JitterPolicy {
None,
Full,
Equal,
RandomizedBand,
}Expand description
Policy controlling randomization of retry delays.
Most users configure this through BackoffPolicy.
§Trade-offs
RandomizedBand: can exceed the base delay when used byBackoffPolicy.Equal: balanced; keeps about 75% of the base delay on average.None: predictable, but retries can line up.Full: widest spread below the base delay.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
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.
RandomizedBand
Randomized wideband.
When used by BackoffPolicy::next, the delay is drawn from:
[first, min(base * 3, max)]Here base is the current retry delay before jitter: first * factor^attempt, capped at max.
Implementations§
Source§impl JitterPolicy
impl JitterPolicy
Sourcepub fn apply(&self, delay: Duration) -> Duration
pub fn apply(&self, delay: Duration) -> Duration
Applies context-free jitter to delay.
RandomizedBand needs first and max to build its full band.
This method does not have that context, so RandomizedBand falls back to Full-style jitter: [0, delay].
For full band behavior, use Self::apply_randomized_band.
Trait Implementations§
Source§impl Clone for JitterPolicy
impl Clone for JitterPolicy
Source§fn clone(&self) -> JitterPolicy
fn clone(&self) -> JitterPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for JitterPolicy
Source§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).