pub struct RetryConfig {
pub max_retries: u32,
pub initial_delay: Duration,
pub max_delay: Duration,
pub multiplier: f64,
pub jitter: JitterKind,
pub jitter_ratio: f64,
}Expand description
Exponential backoff retry parameters.
Adapters consume this configuration to drive retry loops.
The struct itself is pure data; the actual sleep call
is left to the adapter (which has access to tokio::time).
Fields§
§max_retries: u32Maximum number of retry attempts after the first failure.
initial_delay: DurationInitial delay between attempts.
max_delay: DurationMaximum delay (caps the exponential growth).
multiplier: f64Multiplier applied to the delay after each failure.
jitter: JitterKindJitter strategy to add randomness and avoid thundering herd.
jitter_ratio: f64Jitter ratio for Uniform jitter (0.0-1.0). Default 0.25 = ±25%.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn base_delay(&self, attempt: u32) -> Duration
pub fn base_delay(&self, attempt: u32) -> Duration
Compute the base delay for a given attempt number (0-indexed).
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
Compute the delay with jitter for a given attempt number (0-indexed).
Uses rand crate when available, falls back to a simple
deterministic hash-based jitter for no-std / no-rand environments.
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn with_uniform_jitter(self, ratio: f64) -> Self
pub fn with_uniform_jitter(self, ratio: f64) -> Self
Create a config with uniform jitter (±ratio).
Sourcepub fn with_full_jitter(self) -> Self
pub fn with_full_jitter(self) -> Self
Create a config with full jitter (random between 0 and delay).
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more