Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Xuanwo/backon
Retry with backoff without effort.
https://github.com/Xuanwo/backon
async backoff retry rust
Last synced: 3 months ago
JSON representation
Retry with backoff without effort.
- Host: GitHub
- URL: https://github.com/Xuanwo/backon
- Owner: Xuanwo
- License: apache-2.0
- Created: 2022-04-12T11:48:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-20T14:00:37.000Z (6 months ago)
- Last Synced: 2024-07-19T10:03:20.866Z (4 months ago)
- Topics: async, backoff, retry, rust
- Language: Rust
- Homepage: https://docs.rs/backon/
- Size: 74.2 KB
- Stars: 419
- Watchers: 3
- Forks: 18
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- my-awesome - Xuanwo/backon - 10 star:0.7k fork:0.0k Make retry like a built-in feature provided by Rust. (Rust)
README
# backon [![Build Status]][actions] [![Latest Version]][crates.io] [![](https://img.shields.io/discord/1111711408875393035?logo=discord&label=discord)](https://discord.gg/8ARnvtJePD)
[Build Status]: https://img.shields.io/github/actions/workflow/status/Xuanwo/backon/ci.yml?branch=main
[actions]: https://github.com/Xuanwo/backon/actions?query=branch%3Amain
[Latest Version]: https://img.shields.io/crates/v/backon.svg
[crates.io]: https://crates.io/crates/backon
Retry with backoff without effort.
---
The opposite backoff implementation of the popular [backoff](https://docs.rs/backoff).
- Newer: developed by Rust edition 2021 and latest stable.
- Cleaner: Iterator based abstraction, easy to use, customization friendly.
- Easier: Trait based implementations, works like a native function provided by closures.## Quick Start
Retry a blocking function.
```rust
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::ExponentialBuilder;
use backon::Retryable;async fn fetch() -> Result {
Ok(reqwest::get("https://www.rust-lang.org").await?.text().await?)
}#[tokio::main]
async fn main() -> Result<()> {
let content = fetch.retry(&ExponentialBuilder::default()).await?;
println!("fetch succeeded: {}", content);Ok(())
}
```## Contributing
Check out the [CONTRIBUTING.md](./CONTRIBUTING.md) guide for more details on getting started with contributing to this
project.## Getting help
Submit [issues](https://github.com/Xuanwo/backon/issues/new/choose) for bug report or asking questions
in [discussion](https://github.com/Xuanwo/backon/discussions/new?category=q-a).#### License
Licensed under Apache License, Version 2.0.