SimpleRetryConfig

Struct SimpleRetryConfig 

Source
pub struct SimpleRetryConfig { /* private fields */ }
Expand description

Simple retry configuration implementation

This is the simplest RetryConfig implementation, with all configuration fields stored directly in the struct, without depending on an external configuration system. Suitable for scenarios requiring direct control over all configurations.

§Features

  • Simple and Direct: All fields stored directly, no configuration system needed
  • Type Safe: Use Rust’s type system to ensure correct configuration
  • High Performance: No configuration queries, direct field access
  • Easy to Understand: Clear structure, simple code

§Example

use prism3_retry::{SimpleRetryConfig, RetryConfig, RetryDelayStrategy};
use std::time::Duration;

let mut config = SimpleRetryConfig::new();
config
    .set_max_attempts(3)
    .set_max_duration(Some(Duration::from_secs(30)))
    .set_fixed_delay_strategy(Duration::from_secs(1));

assert_eq!(config.max_attempts(), 3);
assert_eq!(config.max_duration(), Some(Duration::from_secs(30)));

§Author

Haixing Hu

Implementations§

Source§

impl SimpleRetryConfig

Source

pub fn new() -> Self

Create a new SimpleRetryConfig instance with default configuration

§Returns

Returns a new SimpleRetryConfig instance with default configuration

§Example
use prism3_retry::{SimpleRetryConfig, RetryConfig};

let config = SimpleRetryConfig::new();
assert_eq!(config.max_attempts(), 5);
Source

pub fn with_params( max_attempts: u32, delay_strategy: RetryDelayStrategy, jitter_factor: f64, max_duration: Option<Duration>, operation_timeout: Option<Duration>, ) -> Self

Create a new SimpleRetryConfig instance with specified parameters

§Parameters
  • max_attempts - Maximum number of attempts
  • delay_strategy - Delay strategy
  • jitter_factor - Jitter factor
  • max_duration - Maximum duration
  • operation_timeout - Single operation timeout
§Returns

Returns a new SimpleRetryConfig instance with the specified parameters

§Example
use prism3_retry::{SimpleRetryConfig, RetryDelayStrategy};
use std::time::Duration;

let config = SimpleRetryConfig::with_params(
    3,
    RetryDelayStrategy::fixed(Duration::from_secs(1)),
    0.1,
    Some(Duration::from_secs(30)),
    Some(Duration::from_secs(5)),
);

Trait Implementations§

Source§

impl Clone for SimpleRetryConfig

Source§

fn clone(&self) -> SimpleRetryConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SimpleRetryConfig

Source§

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

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

impl Default for SimpleRetryConfig

Source§

fn default() -> Self

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

impl RetryConfig for SimpleRetryConfig

Source§

fn max_attempts(&self) -> u32

Get maximum number of attempts Read more
Source§

fn set_max_attempts(&mut self, max_attempts: u32) -> &mut Self

Set maximum number of attempts
Source§

fn max_duration(&self) -> Option<Duration>

Get maximum duration for retry execution Read more
Source§

fn set_max_duration(&mut self, max_duration: Option<Duration>) -> &mut Self

Set maximum duration for retry execution
Source§

fn operation_timeout(&self) -> Option<Duration>

Get single operation timeout Read more
Source§

fn set_operation_timeout(&mut self, timeout: Option<Duration>) -> &mut Self

Set single operation timeout Read more
Source§

fn delay_strategy(&self) -> RetryDelayStrategy

Get delay strategy type
Source§

fn set_delay_strategy( &mut self, delay_strategy: RetryDelayStrategy, ) -> &mut Self

Set delay strategy type
Source§

fn jitter_factor(&self) -> f64

Get jitter factor Read more
Source§

fn set_jitter_factor(&mut self, jitter_factor: f64) -> &mut Self

Set jitter factor
Source§

const KEY_MAX_ATTEMPTS: &'static str = "retry.max_attempts"

Configuration key for maximum number of attempts
Source§

const KEY_DELAY_STRATEGY: &'static str = "retry.delay_strategy"

Configuration key for delay strategy
Source§

const KEY_FIXED_DELAY: &'static str = "retry.fixed_delay_millis"

Configuration key for fixed delay time
Source§

const KEY_RANDOM_MIN_DELAY: &'static str = "retry.random_min_delay_millis"

Configuration key for random delay minimum value
Source§

const KEY_RANDOM_MAX_DELAY: &'static str = "retry.random_max_delay_millis"

Configuration key for random delay maximum value
Source§

const KEY_BACKOFF_INITIAL_DELAY: &'static str = "retry.backoff_initial_delay_millis"

Configuration key for exponential backoff initial delay
Source§

const KEY_BACKOFF_MAX_DELAY: &'static str = "retry.backoff_max_delay_millis"

Configuration key for exponential backoff maximum delay
Source§

const KEY_BACKOFF_MULTIPLIER: &'static str = "retry.backoff_multiplier"

Configuration key for exponential backoff multiplier
Source§

const KEY_JITTER_FACTOR: &'static str = "retry.jitter_factor"

Configuration key for jitter factor
Source§

const KEY_MAX_DURATION: &'static str = "retry.max_duration_millis"

Configuration key for maximum duration of retry execution
Source§

const KEY_OPERATION_TIMEOUT: &'static str = "retry.operation_timeout_millis"

Configuration key for single operation timeout
Source§

const DEFAULT_MAX_ATTEMPTS: u32 = 5u32

Default maximum number of attempts for retry mechanism
Source§

const DEFAULT_DELAY_STRATEGY: RetryDelayStrategy = _

Default delay strategy
Source§

const DEFAULT_FIXED_DELAY_MILLIS: u64 = 1_000u64

Default fixed delay time in milliseconds
Source§

const DEFAULT_RANDOM_MIN_DELAY_MILLIS: u64 = 1_000u64

Default random delay minimum value in milliseconds
Source§

const DEFAULT_RANDOM_MAX_DELAY_MILLIS: u64 = 10_000u64

Default random delay maximum value in milliseconds
Source§

const DEFAULT_BACKOFF_INITIAL_DELAY_MILLIS: u64 = 1_000u64

Default exponential backoff initial delay in milliseconds
Source§

const DEFAULT_BACKOFF_MAX_DELAY_MILLIS: u64 = 60_000u64

Default exponential backoff maximum delay in milliseconds
Source§

const DEFAULT_BACKOFF_MULTIPLIER: f64 = 2f64

Default exponential backoff multiplier
Source§

const DEFAULT_JITTER_FACTOR: f64 = 0f64

Default value for jitter factor
Source§

const DEFAULT_MAX_DURATION_MILLIS: u64 = 0u64

Default maximum duration for retry execution in milliseconds, 0 means unlimited
Source§

const DEFAULT_OPERATION_TIMEOUT_MILLIS: u64 = 0u64

Default value for single operation timeout in milliseconds, 0 means unlimited
Source§

fn set_random_delay_strategy( &mut self, min_delay: Duration, max_delay: Duration, ) -> &mut Self

Set random delay range Read more
Source§

fn set_fixed_delay_strategy(&mut self, delay: Duration) -> &mut Self

Set fixed delay Read more
Source§

fn set_exponential_backoff_strategy( &mut self, initial_delay: Duration, max_delay: Duration, multiplier: f64, ) -> &mut Self

Set exponential backoff strategy parameters Read more
Source§

fn set_no_delay_strategy(&mut self) -> &mut Self

Set no delay strategy Read more
Source§

fn set_unlimited_duration(&mut self) -> &mut Self

Set unlimited duration Read more
Source§

fn set_unlimited_operation_timeout(&mut self) -> &mut Self

Set unlimited operation timeout Read more

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