Module recovery

Source
Expand description

Error recovery patterns for handling transient errors

This module provides various error recovery strategies that can be used to make applications more resilient to transient failures.

§Features

  • Backoff strategies for controlling retry timing
  • Circuit breaker pattern to prevent cascading failures
  • Retry policies for flexible retry behaviors

§Examples

use error_forge::recovery::{ExponentialBackoff, RetryPolicy};

let backoff = ExponentialBackoff::new()
    .with_initial_delay(100)
    .with_max_delay(10000)
    .with_jitter(true);

let policy = RetryPolicy::new(backoff)
    .with_max_retries(3);

let result = policy.retry(|| {
    // Operation that might fail
    Ok(())
});

Structs§

CircuitBreaker
Circuit breaker implementation to prevent cascading failures
CircuitBreakerConfig
Configuration for a circuit breaker
CircuitOpenError
Error returned when circuit is open
ExponentialBackoff
Exponential backoff strategy with optional jitter
FixedBackoff
Fixed backoff strategy
LinearBackoff
Linear backoff strategy
RetryExecutor
Executor for retry operations
RetryPolicy
Policy for retrying operations

Enums§

CircuitState
Represents the current state of a circuit breaker

Traits§

Backoff
Trait for backoff strategies used in retry mechanisms
ForgeErrorRecovery
Extension trait that adds recovery capabilities to ForgeError types

Type Aliases§

RecoveryResult
Result type for recovery operations