pub struct RetryPolicy {
pub max_retries: u32,
pub initial_delay: Duration,
pub max_delay: Duration,
pub multiplier: f64,
pub jitter: bool,
pub max_elapsed_time: Option<Duration>,
pub retry_conditions: Vec<RetryCondition>,
}Expand description
Advanced retry policy with configurable strategies
Fields§
§max_retries: u32Maximum number of retry attempts
initial_delay: DurationInitial delay between retries
max_delay: DurationMaximum delay between retries
multiplier: f64Exponential backoff multiplier
jitter: boolWhether to add jitter to delays
max_elapsed_time: Option<Duration>Maximum total time to spend retrying
retry_conditions: Vec<RetryCondition>Specific error conditions to retry on
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn exponential() -> Self
pub fn exponential() -> Self
Create a new retry policy with exponential backoff
Sourcepub fn max_retries(self, max_retries: u32) -> Self
pub fn max_retries(self, max_retries: u32) -> Self
Set maximum number of retries
Sourcepub fn initial_delay(self, delay: Duration) -> Self
pub fn initial_delay(self, delay: Duration) -> Self
Set initial delay
Sourcepub fn multiplier(self, multiplier: f64) -> Self
pub fn multiplier(self, multiplier: f64) -> Self
Set backoff multiplier
Sourcepub fn max_elapsed_time(self, max_elapsed: Duration) -> Self
pub fn max_elapsed_time(self, max_elapsed: Duration) -> Self
Set maximum elapsed time
Sourcepub fn retry_conditions(self, conditions: Vec<RetryCondition>) -> Self
pub fn retry_conditions(self, conditions: Vec<RetryCondition>) -> Self
Set retry conditions
Sourcepub fn should_retry(&self, error: &AnthropicError) -> bool
pub fn should_retry(&self, error: &AnthropicError) -> bool
Check if an error should be retried
Sourcepub fn calculate_delay(&self, attempt: u32) -> Duration
pub fn calculate_delay(&self, attempt: u32) -> Duration
Calculate next delay using exponential backoff
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
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 RetryPolicy
impl Debug for RetryPolicy
Auto Trait Implementations§
impl Freeze for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin for RetryPolicy
impl UnwindSafe for RetryPolicy
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