diff --git a/Cargo.toml b/Cargo.toml index 9af1821..b029cbc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ documentation = "https://docs.rs/backon" edition = "2021" license = "Apache-2.0" name = "backon" -version = "0.2.0" +version = "0.3.0" [dependencies] futures = "0.3" diff --git a/README.md b/README.md index b29edde..fd828f4 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,31 @@ The opposite backoff implementation of the popular [backoff](https://docs.rs/bac ## Quick Start +Retry a blocking function. + ```rust -use backon::Retryable; -use backon::ExponentialBackoff; use anyhow::Result; +use backon::BlockingRetryable; +use backon::ExponentialBuilder; + +fn fetch() -> Result { + Ok("hello, world!".to_string()) +} + +fn main() -> Result<()> { + let content = fetch.retry(ExponentialBuilder::default()).call()?; + println!("fetch succeeded: {}", content); + + Ok(()) +} +``` + +Retry an async function. + +```rust +use anyhow::Result; +use backon::ExponentialBackoff; +use backon::Retryable; async fn fetch() -> Result { Ok(reqwest::get("https://www.rust-lang.org").await?.text().await?)