Expand description
Exponential-backoff retry for async operations.
Build a RetryStrategy with the desired delays and attempt limit, then
run an operation with retry or
with_exponential_backoff.
Failures sleep before the next attempt with the delay doubling each time up
to the maximum; exhaustion returns RetryExhaustedError.
Key types: RetryStrategy for configuration and execution,
RetryExhaustedError for the terminal failure.
Use this module when a call may fail transiently and is safe to repeat.
ⓘ
let strategy = RetryStrategy::new()
.with_base_delay(Duration::from_millis(100))
.with_max_delay(Duration::from_secs(5))
.with_max_attempts(3);
strategy.retry(|| async { Ok::<_, std::io::Error>("ok".to_string()) }).awaitStructs§
- Retry
Exhausted Error - Terminal failure after all retry attempts were used.
- Retry
Strategy - Configurable exponential-backoff policy.