1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
//! This library provides extensible asynchronous retry behaviours //! for use with the ecosystem of [`tokio`](https://tokio.rs/) libraries. //! //! # Installation //! //! Add this to your `Cargo.toml`: //! //! ```toml //! [dependencies] //! tokio-retry = "0.3" //! ``` //! //! # Example //! //! ```rust,no_run //! # extern crate tokio; //! # extern crate tokio_retry; //! # //! use tokio_retry::Retry; //! use tokio_retry::strategy::{ExponentialBackoff, jitter}; //! //! async fn action() -> Result<u64, ()> { //! // do some real-world stuff here... //! Err(()) //! } //! //! # #[tokio::main] //! # async fn main() -> Result<(), ()> { //! let retry_strategy = ExponentialBackoff::from_millis(10) //! .map(jitter) // add jitter to delays //! .take(3); // limit to 3 retries //! //! let result = Retry::spawn(retry_strategy, action).await?; //! # Ok(()) //! # } //! ``` #![allow(warnings)] mod action; mod condition; mod future; /// Assorted retry strategies including fixed interval and exponential back-off. pub mod strategy; pub use action::Action; pub use condition::Condition; pub use future::{Retry, RetryIf};