pub struct RetryConfig {
pub max_retry_count: Option<u32>,
pub retry_delay_secs: Option<u64>,
}Expand description
Configuration for HTTP request retry behavior.
Retry is always finite: when a field is unset the finite defaults
DEFAULT_MAX_RETRIES and DEFAULT_RETRY_DELAY_SECS apply. Unbounded
retry was removed in PR #26 and must not be reintroduced.
Fields§
§max_retry_count: Option<u32>Maximum number of retries on transient failures.
None means “use DEFAULT_MAX_RETRIES” — it is never interpreted as
infinite retries.
retry_delay_secs: Option<u64>Base delay in seconds between retries.
None means “use DEFAULT_RETRY_DELAY_SECS”. This value is the base
for exponential backoff, not a fixed per-attempt delay.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new retry configuration with the finite defaults.
Equivalent to RetryConfig::default: reads MAX_RETRY_COUNT /
RETRY_DELAY_SECS from the environment when set, otherwise uses
DEFAULT_MAX_RETRIES and DEFAULT_RETRY_DELAY_SECS.
Sourcepub fn infinite() -> Self
👎Deprecated: unbounded retry is banned; use a finite RetryConfig
pub fn infinite() -> Self
unbounded retry is banned; use a finite RetryConfig
Deprecated: unbounded retry is banned (PR #26).
Previously this returned a config with infinite retries. It now clamps to
DEPRECATED_INFINITE_RETRY_CAP — a large but finite cap — so callers
keep compiling while never looping forever. Use RetryConfig::default
or RetryConfig::with_max_retries instead.
Uses RETRY_DELAY_SECS when set, otherwise DEFAULT_RETRY_DELAY_SECS.
Sourcepub fn with_max_retries(max_retries: u32) -> Self
pub fn with_max_retries(max_retries: u32) -> Self
Creates a new retry configuration with a maximum number of retries.
Uses RETRY_DELAY_SECS when set, otherwise DEFAULT_RETRY_DELAY_SECS.
Sourcepub fn with_delay(delay_secs: u64) -> Self
👎Deprecated: unbounded retry is banned; use a finite RetryConfig
pub fn with_delay(delay_secs: u64) -> Self
unbounded retry is banned; use a finite RetryConfig
Deprecated: this constructor left the retry count unbounded.
It now clamps the retry count to DEPRECATED_INFINITE_RETRY_CAP — a
large but finite cap — while still applying the custom base delay. Use
RetryConfig::with_max_retries_and_delay for an explicit finite cap.
Sourcepub fn with_max_retries_and_delay(max_retries: u32, delay_secs: u64) -> Self
pub fn with_max_retries_and_delay(max_retries: u32, delay_secs: u64) -> Self
Creates a new retry configuration with both max retries and custom delay.
Sourcepub fn max_retries(&self) -> u32
pub fn max_retries(&self) -> u32
Gets the maximum retry count.
Always finite: returns DEFAULT_MAX_RETRIES when unconfigured. A value
of 0 means “try once, never retry”; it is never treated as infinite.
Sourcepub fn delay_secs(&self) -> u64
pub fn delay_secs(&self) -> u64
Gets the base retry delay in seconds.
Returns DEFAULT_RETRY_DELAY_SECS when unconfigured.
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
Computes the backoff delay before the given 0-based retry attempt.
Exponential: base * 2^attempt seconds, where base is
RetryConfig::delay_secs, saturating at MAX_RETRY_DELAY_SECS. The
cap is the policy, so rounding down to it is intentional. A jitter of
[0, 25%] of the delay is added to avoid thundering-herd retries; the
jitter entropy comes from the current wall-clock subsecond nanoseconds
(this is jitter, not cryptographic randomness).
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
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 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>,
Source§impl Display for RetryConfig
impl Display 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 UnsafeUnpin 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
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<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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more