This is supported on crate feature network only.
Expand description

Retry utilities.

This module provides an API for retrying fallible asynchronous operations until they succeed or until some criteria for giving up has been reached, using exponential backoff between retries.

Examples

Retry a contrived fallible operation until it succeeds:

use std::time::Duration;
use mz_ore::retry::Retry;

let res = Retry::default().retry(|state| {
   if state.i == 3 {
       Ok(())
   } else {
       Err("contrived failure")
   }
});
assert_eq!(res, Ok(()));

Limit the number of retries such that success is never observed:

use std::time::Duration;
use mz_ore::retry::Retry;

let res = Retry::default().max_tries(2).retry(|state| {
   if state.i == 3 {
       Ok(())
   } else {
       Err("contrived failure")
   }
});
assert_eq!(res, Err("contrived failure"));

Structs

Configures a retry operation.

Wrapper of a Reader factory that will automatically retry and resume reading an underlying resource in the events of errors according to a retry schedule.

The state of a retry operation constructed with Retry.

Opaque type representing the stream of retries that continues to back off.