fetch_with_retry

Function fetch_with_retry 

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

Retry fetch with exponential back-off according to policy.

On each failure the delay doubles (capped at 60 s). Returns the first successful result or the last error if all attempts fail.

The closure is called with the attempt index (0-based) so callers can log retries or vary the request slightly on each attempt.