pub struct Retry<T, E> { /* private fields */ }Expand description
Retry configuration: attempt cap, backoff, jitter, classification, budget.
Implementations§
Source§impl<T, E> Retry<T, E>
impl<T, E> Retry<T, E>
Sourcepub fn exponential() -> Self
pub fn exponential() -> Self
Exponential backoff (default 3 attempts, 100ms base, 10s max, no jitter).
Sourcepub fn standard() -> Self
pub fn standard() -> Self
Sensible default schedule: exponential + full jitter, 4 attempts.
Pair with .when(..) for transient-only classification (see spec §6).
pub fn max_attempts(self, n: u32) -> Self
pub fn max_elapsed(self, d: Duration) -> Self
pub fn base_delay(self, d: Duration) -> Self
pub fn max_delay(self, d: Duration) -> Self
pub fn jitter(self, j: Jitter) -> Self
Sourcepub fn budget(self, budget: RetryBudget) -> Self
pub fn budget(self, budget: RetryBudget) -> Self
Attach a shared RetryBudget to bound retries across calls.
pub fn when(self, pred: impl Fn(&E) -> bool + Send + Sync + 'static) -> Self
pub fn when_outcome( self, f: impl Fn(&Result<T, E>) -> RetryDecision + Send + Sync + 'static, ) -> Self
Sourcepub fn retry_after(
self,
f: impl Fn(&E) -> Option<Duration> + Send + Sync + 'static,
) -> Self
pub fn retry_after( self, f: impl Fn(&E) -> Option<Duration> + Send + Sync + 'static, ) -> Self
Extract an explicit delay hint from an error (e.g. a server-supplied
Retry-After duration). When the extractor returns Some(hint), the
next delay is max(backoff, hint) — the hint acts as a floor.
The result is still capped by max_backoff (if set) and will not
exceed the remaining total_timeout budget (the engine stops instead
of overshooting). Jitter applies normally on top of the chosen delay.
No HTTP, gRPC, or any other dependency is introduced — the closure
receives &E and you parse whatever field you need.