pub struct RetryConfig {
pub max_retries: usize,
pub initial_delay: Duration,
pub max_delay: Duration,
pub backoff_multiplier: f64,
pub retry_on: RetryOn,
}Expand description
Configuration for retry behavior.
Fields§
§max_retries: usizeMaximum number of retry attempts (not counting the initial call).
initial_delay: DurationInitial delay before the first retry.
max_delay: DurationMaximum delay between retries (caps exponential growth).
backoff_multiplier: f64Multiplier applied to the delay after each attempt. A value of 2.0 means each retry waits twice as long as the previous.
retry_on: RetryOnWhich errors should trigger a retry.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn new(max_retries: usize) -> Self
pub fn new(max_retries: usize) -> Self
Creates a new RetryConfig with the specified max retries and defaults for other fields.
Sourcepub fn with_initial_delay(self, delay: Duration) -> Self
pub fn with_initial_delay(self, delay: Duration) -> Self
Sets the initial delay.
Sourcepub fn with_max_delay(self, delay: Duration) -> Self
pub fn with_max_delay(self, delay: Duration) -> Self
Sets the maximum delay.
Sourcepub fn with_backoff_multiplier(self, multiplier: f64) -> Self
pub fn with_backoff_multiplier(self, multiplier: f64) -> Self
Sets the backoff multiplier.
Sourcepub fn with_retry_on(self, retry_on: RetryOn) -> Self
pub fn with_retry_on(self, retry_on: RetryOn) -> Self
Sets which errors should trigger a retry.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate the configuration at construction time.
A non-finite or non-positive backoff_multiplier used to propagate
all the way into Duration::from_secs_f64 (a panic) or silently
collapse retries to zero delay via the runtime clamp. Likewise an
initial_delay above max_delay makes the cap meaningless. Both are
rejected here so misconfiguration fails fast before the first call.