pub struct EnhancedRetryConfig {
pub max_attempts: u32,
pub base_delay_ms: u64,
pub max_delay_ms: u64,
pub max_elapsed_time_ms: u64,
pub jitter_ms: u64,
pub backoff_multiplier: f64,
}Expand description
Enhanced retry configuration for HTTP requests
Fields§
§max_attempts: u32Maximum number of retry attempts
base_delay_ms: u64Base delay in milliseconds between retries
max_delay_ms: u64Maximum delay in milliseconds between retries
max_elapsed_time_ms: u64Maximum elapsed time for all retry attempts in milliseconds
jitter_ms: u64Jitter amount in milliseconds to add randomness
backoff_multiplier: f64Multiplier for exponential backoff (default : 2.0)
Implementations§
Source§impl EnhancedRetryConfig
impl EnhancedRetryConfig
Sourcepub fn with_max_attempts(self, max_attempts: u32) -> Self
pub fn with_max_attempts(self, max_attempts: u32) -> Self
Set maximum retry attempts
Sourcepub fn with_base_delay(self, base_delay_ms: u64) -> Self
pub fn with_base_delay(self, base_delay_ms: u64) -> Self
Set base delay between retries
Sourcepub fn with_max_delay(self, max_delay_ms: u64) -> Self
pub fn with_max_delay(self, max_delay_ms: u64) -> Self
Set maximum delay between retries
Sourcepub fn with_max_elapsed_time(self, max_elapsed_time_ms: u64) -> Self
pub fn with_max_elapsed_time(self, max_elapsed_time_ms: u64) -> Self
Set maximum elapsed time for all attempts
Sourcepub fn with_jitter(self, jitter_ms: u64) -> Self
pub fn with_jitter(self, jitter_ms: u64) -> Self
Set jitter amount for randomization
Sourcepub fn with_backoff_multiplier(self, multiplier: f64) -> Self
pub fn with_backoff_multiplier(self, multiplier: f64) -> Self
Set backoff multiplier for exponential backoff
Sourcepub fn calculate_delay(&self, attempt: u32) -> Duration
pub fn calculate_delay(&self, attempt: u32) -> Duration
Calculate retry delay with exponential backoff and jitter
Formula : base_delay * backoff_multiplier^attempt + random(0, jitter_ms)
Sourcepub fn is_retryable_error(&self, error: &OpenAIError) -> bool
pub fn is_retryable_error(&self, error: &OpenAIError) -> bool
Check if an error is retryable
Trait Implementations§
Source§impl Clone for EnhancedRetryConfig
impl Clone for EnhancedRetryConfig
Source§fn clone(&self) -> EnhancedRetryConfig
fn clone(&self) -> EnhancedRetryConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EnhancedRetryConfig
impl Debug for EnhancedRetryConfig
Source§impl Default for EnhancedRetryConfig
impl Default for EnhancedRetryConfig
Source§impl<'de> Deserialize<'de> for EnhancedRetryConfig
impl<'de> Deserialize<'de> for EnhancedRetryConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for EnhancedRetryConfig
impl RefUnwindSafe for EnhancedRetryConfig
impl Send for EnhancedRetryConfig
impl Sync for EnhancedRetryConfig
impl Unpin for EnhancedRetryConfig
impl UnsafeUnpin for EnhancedRetryConfig
impl UnwindSafe for EnhancedRetryConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<C, E> EntryToVal<C> for Ewhere
C: Collection<Entry = E>,
impl<C, E> EntryToVal<C> for Ewhere
C: Collection<Entry = E>,
Source§type Val = <C as Collection>::Val
type Val = <C as Collection>::Val
Entry in complex collections.
For example, in a HashMap, while Entry might be a ( key, value ) tuple, Val might only be the value part.Source§fn entry_to_val(self) -> <E as EntryToVal<C>>::Val
fn entry_to_val(self) -> <E as EntryToVal<C>>::Val
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<C, Val> ValToEntry<C> for Valwhere
C: CollectionValToEntry<Val>,
impl<C, Val> ValToEntry<C> for Valwhere
C: CollectionValToEntry<Val>,
Source§fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry
fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry
Invokes the val_to_entry function of the CollectionValToEntry trait to convert the value to an entry.
Source§type Entry = <C as CollectionValToEntry<Val>>::Entry
type Entry = <C as CollectionValToEntry<Val>>::Entry
Entry is defined by the Collection trait.