Extensible, asynchronous retry behaviours for the ecosystem of tokio libraries.
Add this to your Cargo.toml
:
toml
[dependencies]
tokio-retry = "0.3"
```rust use tokioretry::Retry; use tokioretry::strategy::{ExponentialBackoff, jitter};
async fn action() -> Result async fn main() -> Result<(), ()> {
let retrystrategy = ExponentialBackoff::frommillis(10)
.map(jitter) // add jitter to delays
.take(3); // limit to 3 retries }
```[tokio::main]
let result = Retry::spawn(retry_strategy, action).await?;
Ok(())