pub struct RetryConfig {
pub max_attempts: u32,
pub initial_backoff: Duration,
pub max_backoff: Duration,
pub multiplier: f64,
pub jitter: bool,
pub retry_on_rate_limit: bool,
pub retry_on_transport: bool,
pub retry_on_timeout: bool,
}Expand description
Configuration for retry behavior.
Fields§
§max_attempts: u32Maximum number of retry attempts
initial_backoff: DurationInitial backoff duration before the first retry
max_backoff: DurationMaximum backoff duration
multiplier: f64Multiplier for exponential backoff
jitter: boolWhether to add jitter to prevent thundering herd
retry_on_rate_limit: boolWhether to retry on rate limit errors
retry_on_transport: boolWhether to retry on transport errors
retry_on_timeout: boolWhether to retry on timeout errors
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn builder() -> RetryConfigBuilder
pub fn builder() -> RetryConfigBuilder
Create a new retry configuration builder.
Sourcepub fn with_max_attempts(self, max_attempts: u32) -> Self
pub fn with_max_attempts(self, max_attempts: u32) -> Self
Set the maximum number of attempts.
Sourcepub fn with_initial_backoff(self, initial_backoff: Duration) -> Self
pub fn with_initial_backoff(self, initial_backoff: Duration) -> Self
Set the initial backoff duration.
Sourcepub fn with_max_backoff(self, max_backoff: Duration) -> Self
pub fn with_max_backoff(self, max_backoff: Duration) -> Self
Set the maximum backoff duration.
Sourcepub fn with_multiplier(self, multiplier: f64) -> Self
pub fn with_multiplier(self, multiplier: f64) -> Self
Set the backoff multiplier.
Sourcepub fn with_jitter(self, jitter: bool) -> Self
pub fn with_jitter(self, jitter: bool) -> Self
Enable or disable jitter.
Sourcepub fn with_retry_on_rate_limit(self, retry: bool) -> Self
pub fn with_retry_on_rate_limit(self, retry: bool) -> Self
Set whether to retry on rate limit errors.
Sourcepub fn with_retry_on_transport(self, retry: bool) -> Self
pub fn with_retry_on_transport(self, retry: bool) -> Self
Set whether to retry on transport errors.
Sourcepub fn with_retry_on_timeout(self, retry: bool) -> Self
pub fn with_retry_on_timeout(self, retry: bool) -> Self
Set whether to retry on timeout errors.
Sourcepub fn should_retry(&self, error: &AixError) -> bool
pub fn should_retry(&self, error: &AixError) -> bool
Check if an error should be retried based on this configuration.
Sourcepub fn calculate_delay(&self, attempt: u32) -> Duration
pub fn calculate_delay(&self, attempt: u32) -> Duration
Sourcepub fn extract_retry_delay(&self, error: &AixError) -> Option<Duration>
pub fn extract_retry_delay(&self, error: &AixError) -> Option<Duration>
Extract retry delay from rate limit error if available.
Source§impl RetryConfig
Preset retry configurations.
impl RetryConfig
Preset retry configurations.
Sourcepub fn conservative() -> Self
pub fn conservative() -> Self
Conservative retry - fewer attempts with longer delays.
Sourcepub fn aggressive() -> Self
pub fn aggressive() -> Self
Aggressive retry - more attempts with shorter initial delays.
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more