Skip to main content

Module recovery

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
  • ForgeError-aware retry executors for sync workloads

§Examples

use error_forge::recovery::RetryPolicy;

let policy = RetryPolicy::new_exponential().with_max_retries(3);

// The operation must declare its error type so the policy can
// type-check the retry loop. Here we use `std::io::Error`.
let result: Result<(), std::io::Error> = policy.retry(|| Ok(()));
assert!(result.is_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