[−][src]Crate tryagain
A crate for trying things again.
tryagain
is a crate to try things again if they fail inspired by
backoff that offers an easier way to cancel
retry attemps and uses a non-blocking async implementation.
Sync example
fn fails() -> Result<(), i32> { Err(0) } // Will never resolve into, will spin forever. let value = tryagain::retry(ImmediateBackoff, fails);
Async example
async fn fails() -> Result<(), i32> { Err(0) } // Will never resolve into, will spin forever. let value = tryagain::future::retry(ImmediateBackoff, fails).await;
Modules
future | An async version of the retry and retry_if function along with RetryFuture used to implement them. |
Structs
ExponentialBackoff | A Backoff implementation that exponentially increases the delay between attempts. |
ImmediateBackoff | A Backoff implementation that doesn't have any delay and retries immediately. |
Traits
Backoff | The implementation of the algorithm used to time when failures should he retried. |
Functions
retry | Retries the provided function if it returns an error whenever the backoff allows. The first call resulting in success will have it's value returned to the caller. |
retry_if | Calls the provided function and if an error is returned it is passed to the predicate to determine if the function should be retried when the backoff function allows. |