Skip to main content

RetryConfig

Struct RetryConfig 

Source
pub struct RetryConfig {
    pub max_attempts: u32,
    pub initial_backoff: Duration,
    pub max_backoff: Duration,
    pub multiplier: f64,
    pub jitter: bool,
    pub retry_on_rate_limit: bool,
    pub retry_on_transport: bool,
    pub retry_on_timeout: bool,
}
Expand description

Configuration for retry behavior.

Fields§

§max_attempts: u32

Maximum number of retry attempts

§initial_backoff: Duration

Initial backoff duration before the first retry

§max_backoff: Duration

Maximum backoff duration

§multiplier: f64

Multiplier for exponential backoff

§jitter: bool

Whether to add jitter to prevent thundering herd

§retry_on_rate_limit: bool

Whether to retry on rate limit errors

§retry_on_transport: bool

Whether to retry on transport errors

§retry_on_timeout: bool

Whether to retry on timeout errors

Implementations§

Source§

impl RetryConfig

Source

pub fn new() -> Self

Create a new retry configuration with sensible defaults.

Source

pub fn builder() -> RetryConfigBuilder

Create a new retry configuration builder.

Source

pub fn with_max_attempts(self, max_attempts: u32) -> Self

Set the maximum number of attempts.

Source

pub fn with_initial_backoff(self, initial_backoff: Duration) -> Self

Set the initial backoff duration.

Source

pub fn with_max_backoff(self, max_backoff: Duration) -> Self

Set the maximum backoff duration.

Source

pub fn with_multiplier(self, multiplier: f64) -> Self

Set the backoff multiplier.

Source

pub fn with_jitter(self, jitter: bool) -> Self

Enable or disable jitter.

Source

pub fn with_retry_on_rate_limit(self, retry: bool) -> Self

Set whether to retry on rate limit errors.

Source

pub fn with_retry_on_transport(self, retry: bool) -> Self

Set whether to retry on transport errors.

Source

pub fn with_retry_on_timeout(self, retry: bool) -> Self

Set whether to retry on timeout errors.

Source

pub fn should_retry(&self, error: &AixError) -> bool

Check if an error should be retried based on this configuration.

Source

pub fn calculate_delay(&self, attempt: u32) -> Duration

Calculate the delay for a given attempt number.

§Arguments
  • attempt - The attempt number (0-based)
§Returns

The duration to wait before the next attempt

Source

pub fn extract_retry_delay(&self, error: &AixError) -> Option<Duration>

Extract retry delay from rate limit error if available.

Source§

impl RetryConfig

Preset retry configurations.

Source

pub fn no_retry() -> Self

No retry - attempt operation only once.

Source

pub fn conservative() -> Self

Conservative retry - fewer attempts with longer delays.

Source

pub fn aggressive() -> Self

Aggressive retry - more attempts with shorter initial delays.

Source

pub fn fast() -> Self

Fast retry - for operations that should retry quickly.

Trait Implementations§

Source§

impl Clone for RetryConfig

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for RetryConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RetryConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<RetryConfig> for RetryStrategy

Source§

fn from(config: RetryConfig) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V