Skip to main content

with_backoff

Function with_backoff 

Source
pub async fn with_backoff<T, F, Fut>(policy: RetryPolicy, op: F) -> Result<T>
where F: FnMut(u32) -> Fut, Fut: Future<Output = Result<T>>,
Expand description

Run op under policy, retrying transient failures with exponential backoff.

Retries on Error::Server / Error::Network (doubled base_delay) and Error::RateLimited (sleeps for the server-supplied retry_after). Any other variant — or exhausting max_attempts — propagates the last error.

op receives the 1-indexed attempt number so callers can log per-try state.