Skip to content

Commit

Permalink
Bump to version 0.3.0 (#28)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored Feb 8, 2023
1 parent 82d7c21 commit d073d88
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
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<String> {
Ok(reqwest::get("https://www.rust-lang.org").await?.text().await?)
Expand Down

0 comments on commit d073d88

Please sign in to comment.