pub struct RetryConfig {
pub max_attempts: u32,
pub initial_delay_ms: u64,
pub max_delay_ms: u64,
pub backoff_multiplier: f64,
pub max_total_delay_ms: u64,
pub rate_limit_buffer_seconds: u64,
pub rate_limit_max_attempts: u32,
pub jitter_enabled: bool,
}
Expand description
Retry configuration for HTTP requests
Fields§
§max_attempts: u32
Maximum number of retry attempts (default: 5)
initial_delay_ms: u64
Initial delay between retries in milliseconds (default: 1000ms)
max_delay_ms: u64
Maximum delay between retries in milliseconds (default: 30000ms)
backoff_multiplier: f64
Exponential backoff multiplier (default: 2.0)
max_total_delay_ms: u64
Maximum total time to spend on retries in milliseconds (default: 300000ms = 5 minutes)
rate_limit_buffer_seconds: u64
Buffer time in seconds to add when waiting for rate limit window reset (default: 5s)
rate_limit_max_attempts: u32
Maximum number of retry attempts specifically for rate limit errors (default: 1)
jitter_enabled: bool
Whether to enable jitter in retry delays (default: true)
Implementations§
Source§impl RetryConfig
impl RetryConfig
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 retry attempts
Sourcepub fn with_initial_delay(self, delay_ms: u64) -> Self
pub fn with_initial_delay(self, delay_ms: u64) -> Self
Set the initial delay between retries
Sourcepub fn with_initial_delay_millis(self, delay_ms: u64) -> Self
pub fn with_initial_delay_millis(self, delay_ms: u64) -> Self
Set the initial delay between retries (alias for compatibility)
Sourcepub fn with_max_delay(self, delay_ms: u64) -> Self
pub fn with_max_delay(self, delay_ms: u64) -> Self
Set the maximum delay between retries
Sourcepub fn with_max_delay_millis(self, delay_ms: u64) -> Self
pub fn with_max_delay_millis(self, delay_ms: u64) -> Self
Set the maximum delay between retries (alias for compatibility)
Sourcepub fn with_backoff_multiplier(self, multiplier: f64) -> Self
pub fn with_backoff_multiplier(self, multiplier: f64) -> Self
Set the exponential backoff multiplier
Sourcepub fn with_exponential_backoff(self, multiplier: f64) -> Self
pub fn with_exponential_backoff(self, multiplier: f64) -> Self
Set the exponential backoff multiplier (alias for compatibility)
Sourcepub fn with_max_total_delay(self, delay_ms: u64) -> Self
pub fn with_max_total_delay(self, delay_ms: u64) -> Self
Set the maximum total time to spend on retries
Sourcepub fn with_rate_limit_buffer(self, buffer_seconds: u64) -> Self
pub fn with_rate_limit_buffer(self, buffer_seconds: u64) -> Self
Set the buffer time to add when waiting for rate limit window reset
Sourcepub fn with_rate_limit_max_attempts(self, max_attempts: u32) -> Self
pub fn with_rate_limit_max_attempts(self, max_attempts: u32) -> Self
Set the maximum number of retry attempts for rate limit errors
Sourcepub fn with_jitter_disabled(self) -> Self
pub fn with_jitter_disabled(self) -> Self
Disable jitter in retry delays
Jitter adds randomness to retry delays to prevent thundering herd problems. Disabling jitter makes retry timing more predictable but may cause synchronized retries from multiple clients.
Sourcepub fn calculate_delay(&self, attempt: u32) -> Duration
pub fn calculate_delay(&self, attempt: u32) -> Duration
Calculate the delay for a given attempt number using exponential backoff
Sourcepub fn calculate_rate_limit_delay(
&self,
retry_after_seconds: Option<u64>,
) -> Duration
pub fn calculate_rate_limit_delay( &self, retry_after_seconds: Option<u64>, ) -> Duration
Calculate the delay for rate limit (429) errors
For Veracode’s 500 requests/minute rate limiting, this calculates the optimal wait time based on the current time within the minute window or uses the server’s Retry-After header if provided.
Sourcepub fn is_retryable_error(&self, error: &VeracodeError) -> bool
pub fn is_retryable_error(&self, error: &VeracodeError) -> bool
Check if an error is retryable based on its type
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