pub struct RetryConfig {
pub max_attempts: u32,
pub base_delay: Duration,
pub max_delay: Duration,
pub multiplier: f64,
pub jitter: f64,
}Expand description
Configuration for a retry schedule.
Fields§
§max_attempts: u32Maximum number of attempts (including the first one). 1 disables retries.
base_delay: DurationBase delay for the first retry.
max_delay: DurationMaximum delay between attempts; the exponential curve caps here.
multiplier: f64Multiplier applied to the delay each attempt (typically 2.0).
jitter: f64Random jitter fraction applied to each computed delay, in [0, 1].
0.0 disables jitter.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn delay_before(&self, attempt: u32) -> Duration
pub fn delay_before(&self, attempt: u32) -> Duration
Compute the sleep before attempt n (0-indexed).
n == 0 → caller is about to make the first attempt, no delay.
n == 1 → delay before the first retry, and so on.
Jitter is drawn from a real per-call entropy source, so callers
retrying in lockstep do not compute identical delays — that
decorrelation is the entire point of jitter (it prevents a
synchronized retry storm against a recovering server). For
reproducible delays in tests, use delay_before_with_jitter.
Sourcepub fn delay_before_with_jitter(
&self,
attempt: u32,
jitter_frac: f64,
) -> Duration
pub fn delay_before_with_jitter( &self, attempt: u32, jitter_frac: f64, ) -> Duration
Like delay_before but with the jitter
fraction supplied explicitly (in [0, 1)). Deterministic — used
by tests, or by callers that want to plug their own RNG.
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more