https://github.com/srijs/rust-tokio-retry
Extensible, asynchronous retry behaviours for futures/tokio
https://github.com/srijs/rust-tokio-retry
retry rust tokio
Last synced: 6 months ago
JSON representation
Extensible, asynchronous retry behaviours for futures/tokio
- Host: GitHub
- URL: https://github.com/srijs/rust-tokio-retry
- Owner: srijs
- License: mit
- Created: 2017-03-05T12:56:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-08-14T14:37:38.000Z (about 2 years ago)
- Last Synced: 2025-04-04T01:08:26.353Z (6 months ago)
- Topics: retry, rust, tokio
- Language: Rust
- Homepage: https://crates.io/crates/tokio-retry
- Size: 58.6 KB
- Stars: 132
- Watchers: 3
- Forks: 28
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tokio-retry
Extensible, asynchronous retry behaviours for the ecosystem of [tokio](https://tokio.rs/) libraries.
[](https://travis-ci.org/srijs/rust-tokio-retry)
[](https://crates.io/crates/tokio-retry)
[](https://deps.rs/repo/github/srijs/rust-tokio-retry)[Documentation](https://docs.rs/tokio-retry)
## Installation
Add this to your `Cargo.toml`:
```toml
[dependencies]
tokio-retry = "0.3"
```## Examples
```rust
use tokio_retry::Retry;
use tokio_retry::strategy::{ExponentialBackoff, jitter};async fn action() -> Result {
// 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 retrieslet result = Retry::spawn(retry_strategy, action).await?;
Ok(())
}
```