sparkling/retry
Retry logic with exponential backoff and jitter for resilient operations. Used by both repo and transport layers to handle transient failures.
Types
Configuration for retry behavior
pub type RetryConfig {
RetryConfig(
max_attempts: Int,
base_delay_ms: Int,
max_delay_ms: Int,
jitter_factor: Float,
)
}
Constructors
-
RetryConfig( max_attempts: Int, base_delay_ms: Int, max_delay_ms: Int, jitter_factor: Float, )Arguments
- max_attempts
-
Maximum number of retry attempts
- base_delay_ms
-
Base delay in milliseconds for exponential backoff
- max_delay_ms
-
Maximum delay between retries
- jitter_factor
-
Jitter factor (0.0 = no jitter, 1.0 = full jitter)
Values
pub fn default_config() -> RetryConfig
Default retry configuration suitable for most operations
pub fn network_config() -> RetryConfig
Configuration optimized for network operations (longer delays)
pub fn with_retry(
config: RetryConfig,
operation: fn() -> Result(a, b),
is_retryable_error: fn(b) -> Bool,
) -> Result(a, b)
Execute an operation with retry logic Returns the result of the first successful attempt, or the last error