Crate retry_fn

Crate retry_fn 

Source
Expand description

§retry

Function for executing retry either as a closure with a std-based sleep (thread::sleep) or using either of the most popular async runtimes. See tokio or async-std module for futures-aware versions.

§Sync Example

use retry_fn::{retry, RetryResult, strategy::ExponentialBackoff};
let mut count = 0;
let res = retry(ExponentialBackoff::new(Duration::from_secs(2)), |op| {
   if op.retries >= 3 {
       RetryResult::<&str, _>::Err(io::Error::new(
           io::ErrorKind::TimedOut,
           "timed out",
       ))
   } else {
       count += 1;
       RetryResult::Retry()
   }
});
assert_eq!(count, 3);
assert!(res.is_err());
Ok(())

Modules§

strategy
Different iterators to retry using

Structs§

RetryOp
RetryOp gives some inspection into the current state of retries

Enums§

RetryErr
Error type for retry
RetryResult
What to do with the current result of the function

Functions§

retry
Retry a function on some time interval
retry_immediate
retry with the ‘immediate’ strategy, i.e. no wait in between attempts