pub struct RetryConfig {
pub max_attempts: u32,
pub base_delay_ms: u64,
pub max_delay_ms: u64,
pub timeout_seconds: u64,
}Expand description
Configuration for retry behavior in API requests
Fields§
§max_attempts: u32Maximum number of retry attempts
base_delay_ms: u64Base delay in milliseconds for exponential backoff
max_delay_ms: u64Maximum delay in milliseconds to cap exponential backoff
timeout_seconds: u64Request timeout in seconds
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn from_env() -> Result<Self, Error>
pub fn from_env() -> Result<Self, Error>
Creates a RetryConfig from environment variables with default fallbacks
Environment variables:
API_RETRY_MAX_ATTEMPTS: Maximum retry attempts (default: 3)API_RETRY_BASE_DELAY_MS: Base delay in milliseconds (default: 1000)API_RETRY_MAX_DELAY_MS: Maximum delay in milliseconds (default: 30000)API_REQUEST_TIMEOUT_SECONDS: Request timeout in seconds (default: 10)
§Errors
Returns an error if any environment variable contains an invalid value
Sourcepub const fn for_tests() -> Self
pub const fn for_tests() -> Self
Creates a RetryConfig optimized for test environments
Uses reduced values for faster test execution:
- 2 retry attempts
- 500ms base delay
- 5000ms max delay
- 5 second timeout
Sourcepub const fn with_timeout(self, timeout_seconds: u64) -> Self
pub const fn with_timeout(self, timeout_seconds: u64) -> Self
Sets a custom timeout value
Sourcepub const fn with_max_attempts(self, max_attempts: u32) -> Self
pub const fn with_max_attempts(self, max_attempts: u32) -> Self
Sets custom max attempts
Sourcepub const fn with_base_delay_ms(self, base_delay_ms: u64) -> Self
pub const fn with_base_delay_ms(self, base_delay_ms: u64) -> Self
Sets custom base delay
Sourcepub const fn with_max_delay_ms(self, max_delay_ms: u64) -> Self
pub const fn with_max_delay_ms(self, max_delay_ms: u64) -> Self
Sets custom max delay
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RetryConfig
impl Debug for RetryConfig
Auto Trait Implementations§
impl Freeze for RetryConfig
impl RefUnwindSafe for RetryConfig
impl Send for RetryConfig
impl Sync for RetryConfig
impl Unpin for RetryConfig
impl UnsafeUnpin for RetryConfig
impl UnwindSafe for RetryConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more