tokio_retry/
lib.rs

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