Debian Codegraph @

/

debian rust-backon 1.6.0-2debian librust-backon-dev debian librust-backon+default-dev debian librust-backon+futures-timer-dev debian librust-backon+futures-timer-sleep-dev debian librust-backon+gloo-timers-sleep-dev debian librust-backon+std-dev debian librust-backon+std-blocking-sleep-dev debian librust-backon+tokio-dev debian librust-backon+tokio-sleep-dev debian librust-backon-1-dev debian librust-backon-1+default-dev debian librust-backon-1+futures-timer-dev debian librust-backon-1+futures-timer-sleep-dev debian librust-backon-1+gloo-timers-sleep-dev debian librust-backon-1+std-dev debian librust-backon-1+std-blocking-sleep-dev debian librust-backon-1+tokio-dev debian librust-backon-1+tokio-sleep-dev debian librust-backon-1.6-dev
18 more… debian librust-backon-1.6+default-dev debian librust-backon-1.6+futures-timer-dev debian librust-backon-1.6+futures-timer-sleep-dev debian librust-backon-1.6+gloo-timers-sleep-dev debian librust-backon-1.6+std-dev debian librust-backon-1.6+std-blocking-sleep-dev debian librust-backon-1.6+tokio-dev debian librust-backon-1.6+tokio-sleep-dev debian librust-backon-1.6.0-dev debian librust-backon-1.6.0+default-dev debian librust-backon-1.6.0+futures-timer-dev debian librust-backon-1.6.0+futures-timer-sleep-dev debian librust-backon-1.6.0+gloo-timers-sleep-dev debian librust-backon-1.6.0+std-dev debian librust-backon-1.6.0+std-blocking-sleep-dev debian librust-backon-1.6.0+tokio-dev debian librust-backon-1.6.0+tokio-sleep-dev cargo backon 1.6.0
debianjsonmakefilemarkdownrustrustrust-c-abishelltoml 41 files · 475 symbols
View dependency graph

Depends on

  • dh-cargo (dh-sequence-cargo)
  • cargo, debhelper-compat, librust-fastrand+std-dev, librust-fastrand-dev, librust-futures-timer-3+default-dev, librust-tokio-1+default-dev, librust-tokio-1+time-dev, libstd-rust-dev, rustc
README (full)

BackON   Build Status Latest Version

BackON

Make retry like a built-in feature provided by Rust.

  • Simple API: Native feel: your_fn.retry(ExponentialBuilder::default()).await.
  • Sync & Async: Supports both blocking and async operations seamlessly.
  • Precise Control: Define when to retry and get notified via when and notify.
  • Custom Strategies: Use built-in backoff strategies (exponential, constant) or define custom ones. Also supports dynamic backoff, such as using the HTTP Retry-After header.
  • Cross-Platform: Works everywhere Rust does, including wasm & no-std.

Quick Start

For more examples, check out the examples.

Retry an async function.

use anyhow::Result;
use backon::ExponentialBuilder;
use backon::Retryable;

async fn fetch() -> Result<String> {
    Ok("hello, world!".to_string())
}

#[tokio::main]
async fn main() -> Result<()> {
    let content = fetch
        // Retry with exponential backoff
        .retry(ExponentialBuilder::default())
        // Sleep implementation, required if no feature has been enabled
        .sleep(tokio::time::sleep)
        // When to retry
        .when(|e| e.to_string() == "EOF")
        // Notify when retrying
        .notify(|err: &anyhow::Error, dur: Duration| {
            println!("retrying {:?} after {:?}", err, dur);
        })
        .await?;
    println!("fetch succeeded: {}", content);

    Ok(())
}

Retry a blocking function.

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 with exponential backoff
        .retry(ExponentialBuilder::default())
        // Sleep implementation, required if no feature has been enabled
        .sleep(std::thread::sleep)
        // When to retry
        .when(|e| e.to_string() == "EOF")
        // Notify when retrying
        .notify(|err: &anyhow::Error, dur: Duration| {
            println!("retrying {:?} after {:?}", err, dur);
        })
        .call()?;
    println!("fetch succeeded: {}", content);

    Ok(())
}

Contributing

Check out the CONTRIBUTING.md guide for more details on getting started with contributing to this project.

Getting help

Submit issues for bug report or asking questions in discussion.

License

Licensed under Apache License, Version 2.0.

dir debian/
dir src/
file .cargo_vcs_info.json
file Cargo.lock
file Cargo.toml
file Cargo.toml.orig
file LICENSE
file README.md