pub async fn with_backoff<F, Fut, T, E>(
config: &RetryConfig,
f: F,
) -> Result<T, RetryError<E>>Expand description
Retry an async operation with exponential backoff.
Calls f repeatedly until it succeeds or the max retries are exhausted.
On each retryable error, waits for the calculated backoff delay before retrying.
Non-retryable errors are returned immediately.
§Example
ⓘ
use retry_backoff::{with_backoff, RetryConfig};
let result = with_backoff(&RetryConfig::default(), || async {
client.get("https://api.example.com/data").await
}).await;