Skip to main content

Crate shipper_retry

Crate shipper_retry 

Source
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§

PerErrorConfig
Per-error-type retry configuration.
RetryExecutor
A retry executor that runs a fallible operation with configured retry behavior.
RetryStrategyConfig
Configuration for a retry strategy.

Enums§

ErrorClass
Error classification for retry decisions.
RetryPolicy
Predefined retry policies with sensible defaults for different use cases.
RetryStrategyType
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.