retry_with_backoff

Function retry_with_backoff 

Source
pub async fn retry_with_backoff<F, T, E>(
    operation: F,
    max_retries: u32,
    operation_name: &str,
) -> Result<T, E>
where F: Fn() -> Pin<Box<dyn Future<Output = Result<T, E>> + Send>>, E: Display,
Expand description

Retry an async operation with exponential backoff.

Attempts the operation up to max_retries times with exponential backoff between attempts.

§Type Parameters

  • F - Future-producing function
  • T - Success result type
  • E - Error type (must implement Display)

§Errors

Returns the last error if all retry attempts fail.