backoff-config 0.0.1

Flexible backoff configuration in Rust
docs.rs failed to build backoff-config-0.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: backoff-config-0.1.4

๐Ÿ”„ backoff-config โš™๏ธ

backoff-config makes configuring backoff more flexible by providing a unified Backoff strategy enum and a BackoffConfig that supports deserialization.

The actual backoff logic is powered by the awesome backon crate. Make sure to check out backon to explore its amazing features and ergonomics!

backoff-config integrates with backon by implementing:

Usage

  1. Add to your Cargo.toml:

    backoff-config = "0.1"
    
  2. Load BackoffConfig from your data source. Hereโ€™s an example using environment variables and the figment configuration library:

use serde::Deserialize;

#[derive(Deserialize)]
pub struct Config {
    pub backoff: BackoffConfig,
}

// Example environment variables:
// CONFIG__BACKOFF__STRATEGY=Constant
// CONFIG__BACKOFF__DELAY=1s
// CONFIG__BACKOFF__MAX_RETRIES=123

let config = figment::Figment::new()
.merge(Env::prefixed("CONFIG__").split("__"))
.extract::<Config>() ?;
  1. Use config.backoff to build and apply your backoff strategy when calling retryable operations.

Examples

For an end-to-end usage example, see the TOML example and run it with:

cargo run --example toml

For more examples on the data formats, see: