pub struct RetryPolicy {
pub max_retries: u32,
pub base: Duration,
pub max_delay: Duration,
pub jitter: f64,
}Expand description
Retry configuration. Governs the exponential-backoff schedule and the jitter distribution applied to each retry delay.
Fields§
§max_retries: u32Maximum number of retry attempts after the initial request.
0 disables retries entirely.
base: DurationBase for the exponential backoff. Delay for attempt n is
base * 2^n, capped at Self::max_delay, then modulated by
jitter.
max_delay: DurationAbsolute upper bound on the pre-jitter delay. Prevents runaway exponentials on high retry counts.
jitter: f64Fraction of the computed delay applied as full-jitter randomness.
Value 0.0..=1.0. 0.0 means no jitter; 1.0 means the delay
can be anywhere in [0, delay].
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub const fn default_full_jitter() -> Self
pub const fn default_full_jitter() -> Self
AWS Architecture Blog’s “full jitter” default: 200 ms base, 30 s cap, 100 % jitter, 3 retries.
Sourcepub fn delay(&self, attempt: u32, rng_0_to_1: f64) -> Duration
pub fn delay(&self, attempt: u32, rng_0_to_1: f64) -> Duration
Compute the delay for a given attempt (0-indexed).
attempt = 0 is the first retry (after the initial request
failed). Delay grows as base * 2^attempt, capped at
max_delay, then modulated by the jitter fraction using a
caller-supplied random source in [0.0, 1.0).