Expand description
Retry strategies and backoff policies for distributed systems.
This crate provides configurable retry strategies with support for:
- Multiple backoff strategies (immediate, exponential, linear, constant)
- Jitter for avoiding thundering herd problems
- Per-error-type configuration
- Predefined policies for common use cases
§Example
use shipper_retry::{RetryPolicy, RetryStrategyConfig, calculate_delay};
use std::time::Duration;
// Use a predefined policy
let config = RetryPolicy::Default.to_config();
let delay = calculate_delay(&config, 2);
println!("Retry after: {:?}", delay);
// Custom configuration
let custom = RetryStrategyConfig {
max_attempts: 5,
base_delay: Duration::from_secs(1),
max_delay: Duration::from_secs(30),
..Default::default()
};Structs§
- PerError
Config - Per-error-type retry configuration.
- Retry
Executor - A retry executor that runs a fallible operation with configured retry behavior.
- Retry
Strategy Config - Configuration for a retry strategy.
Enums§
- Error
Class - Error classification for retry decisions.
- Retry
Policy - Predefined retry policies with sensible defaults for different use cases.
- Retry
Strategy Type - Strategy type for retry behavior.
Functions§
- calculate_
delay - Calculate the delay for the next retry attempt based on the strategy configuration.
- config_
for_ error - Get the retry configuration for a specific error class. Falls back to the default config if no per-error config is specified.