retry_transient

Function retry_transient 

Source
pub async fn retry_transient<F, Fut, T, E, P>(
    operation: F,
    policy: P,
) -> BoxedComposableResult<T, E>
where F: FnMut() -> Fut, Fut: Future<Output = Result<T, E>>, E: TransientError, P: RetryPolicy,
Expand description

Retries an async operation using Tokio’s sleep, returning a boxed error.

This is a convenience wrapper around retry_transient_unboxed that boxes the error for reduced stack size.

§Arguments

  • operation - A closure that returns the future to retry
  • policy - The retry policy to use

§Example

use error_rail::async_ext::{retry_transient, ExponentialBackoff};

#[tokio::main]
async fn main() {
    let result = retry_transient(
        || fetch_data(),
        ExponentialBackoff::default(),
    ).await;
}