pub struct RetryConfig {
pub max_attempts: u32,
pub initial_backoff: Duration,
pub max_backoff: Duration,
pub backoff_multiplier: f32,
pub jitter: bool,
}Expand description
Retry configuration for failed requests.
Fields§
§max_attempts: u32Maximum number of retry attempts
initial_backoff: DurationInitial backoff duration
max_backoff: DurationMaximum backoff duration
backoff_multiplier: f32Backoff multiplier for exponential backoff
jitter: boolAdd random jitter to backoff
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn calculate_backoff(&self, attempt: u32) -> Duration
pub fn calculate_backoff(&self, attempt: u32) -> Duration
Calculate backoff duration for a given attempt.
§Example
use simple_agent_type::config::RetryConfig;
use std::time::Duration;
let config = RetryConfig::default();
let backoff = config.calculate_backoff(1);
assert!(backoff >= Duration::from_millis(100));
assert!(backoff <= Duration::from_millis(200)); // with jitterTrait 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 · 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
Source§impl Default for RetryConfig
impl Default for RetryConfig
Source§impl<'de> Deserialize<'de> for RetryConfig
impl<'de> Deserialize<'de> for RetryConfig
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for RetryConfig
impl PartialEq for RetryConfig
Source§impl Serialize for RetryConfig
impl Serialize for RetryConfig
impl StructuralPartialEq 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 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