Crates.io | finito |
lib.rs | finito |
version | 0.1.0 |
source | src |
created_at | 2024-04-19 10:21:41.91297 |
updated_at | 2024-04-19 10:21:41.91297 |
description | Retry behaviour for futures |
homepage | |
repository | https://github.com/niklasad1/finito |
max_upload_size | |
id | 1213499 |
size | 24,650 |
This library provides retry mechanisms to retry async operations.
It's based off tokio-retry with the difference that it isn't coupled to any specific async runtime and that it compiles for WASM.
use finito::{Retry, ExponentialBackoff};
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).take(3); // limit to 3 retries
let result = Retry::new(retry_strategy, action).await?;
Ok(())
}