pub struct RetryConfig {
pub max_retries: u32,
pub base_delay: Duration,
pub max_delay: Duration,
pub retryable_status_codes: Vec<u16>,
pub circuit_threshold: u32,
pub circuit_timeout: Duration,
pub jitter: f64,
}Expand description
Retry configuration for failed requests.
Fields§
§max_retries: u32Maximum number of retries
base_delay: DurationBase delay between retries (exponential backoff)
max_delay: DurationMaximum delay between retries
retryable_status_codes: Vec<u16>HTTP status codes that should trigger a retry
circuit_threshold: u32Circuit breaker: consecutive failures before opening circuit
circuit_timeout: DurationCircuit breaker: timeout before transitioning from Open to HalfOpen
jitter: f64Jitter factor (0.0-1.0) to add randomness to backoff delays
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
Set maximum number of retries.
Sourcepub fn with_base_delay(self, delay: Duration) -> Self
pub fn with_base_delay(self, delay: Duration) -> Self
Set base delay for exponential backoff.
Sourcepub fn with_max_delay(self, delay: Duration) -> Self
pub fn with_max_delay(self, delay: Duration) -> Self
Set maximum delay for exponential backoff.
Sourcepub fn with_circuit_threshold(self, threshold: u32) -> Self
pub fn with_circuit_threshold(self, threshold: u32) -> Self
Set circuit breaker threshold (consecutive failures before opening).
Sourcepub fn with_circuit_timeout(self, timeout: Duration) -> Self
pub fn with_circuit_timeout(self, timeout: Duration) -> Self
Set circuit breaker timeout (time before trying again).
Sourcepub fn with_jitter(self, jitter: f64) -> Self
pub fn with_jitter(self, jitter: f64) -> Self
Set jitter factor (0.0-1.0) to add randomness to backoff. This helps prevent thundering herd when services recover.
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
Calculate delay for a specific retry attempt with exponential backoff and jitter.
Sourcepub fn is_retryable(&self, status: u16) -> bool
pub fn is_retryable(&self, status: u16) -> bool
Check if a status code should trigger a retry.
Source§impl RetryConfig
Default retry configuration for production use.
More conservative to be a good API citizen.
impl RetryConfig
Default retry configuration for production use. More conservative to be a good API citizen.
Sourcepub fn production() -> Self
pub fn production() -> Self
Production-grade configuration with conservative defaults.
Sourcepub fn development() -> Self
pub fn development() -> Self
Aggressive retry configuration for development/testing.
Sourcepub fn batch_processing() -> Self
pub fn batch_processing() -> Self
Configuration optimized for batch processing with longer delays.
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more