Extensible, asynchronous retry behaviours based on futures, for the ecosystem of tokio libraries.
Add this to your Cargo.toml
:
toml
[dependencies]
tokio-retry = "0.2"
```rust extern crate futures; extern crate tokio; extern crate tokio_retry;
use futures::Future; use tokioretry::Retry; use tokioretry::strategy::{ExponentialBackoff, jitter};
fn action() -> Result fn main() {
let retrystrategy = ExponentialBackoff::frommillis(10)
.map(jitter)
.take(3); }
```let future = Retry::spawn(retry_strategy, action).then(|result| {
println!("result {:?}", result);
Ok(())
});
tokio::run(future);