pub struct StreamRetryPolicy {
pub max_attempts: u32,
pub initial_delay: Duration,
pub backoff_multiplier: f64,
pub max_delay: Duration,
pub jitter: bool,
}Expand description
Configures when and how many times an operation should be retried
Fields§
§max_attempts: u32Maximum number of retry attempts (0 = no retries)
initial_delay: DurationInitial delay before first retry
backoff_multiplier: f64Multiplier applied to delay after each retry (exponential backoff)
max_delay: DurationMaximum delay cap (prevents unbounded backoff)
jitter: boolWhether to add random jitter (fraction of delay) to prevent thundering herd
Implementations§
Source§impl StreamRetryPolicy
impl StreamRetryPolicy
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
Returns the delay before the nth retry attempt (0-indexed).
Incorporates exponential backoff and an optional pseudo-random jitter derived deterministically from the attempt number (no rand crate needed).
Sourcepub fn retry<F, T, E>(&self, operation_name: &str, f: F) -> FaultResult<T>
pub fn retry<F, T, E>(&self, operation_name: &str, f: F) -> FaultResult<T>
Executes a fallible synchronous closure with retries.
Uses std::thread::sleep for backoff delays. For async contexts see
StreamRetryPolicy::retry_async.
Sourcepub async fn retry_async<F, Fut, T, E>(
&self,
operation_name: &str,
f: F,
) -> FaultResult<T>
pub async fn retry_async<F, Fut, T, E>( &self, operation_name: &str, f: F, ) -> FaultResult<T>
Executes a fallible async closure with retries and tokio async sleep.
Trait Implementations§
Source§impl Clone for StreamRetryPolicy
impl Clone for StreamRetryPolicy
Source§fn clone(&self) -> StreamRetryPolicy
fn clone(&self) -> StreamRetryPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StreamRetryPolicy
impl Debug for StreamRetryPolicy
Source§impl Default for StreamRetryPolicy
impl Default for StreamRetryPolicy
Source§impl<'de> Deserialize<'de> for StreamRetryPolicy
impl<'de> Deserialize<'de> for StreamRetryPolicy
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 StreamRetryPolicy
impl RefUnwindSafe for StreamRetryPolicy
impl Send for StreamRetryPolicy
impl Sync for StreamRetryPolicy
impl Unpin for StreamRetryPolicy
impl UnsafeUnpin for StreamRetryPolicy
impl UnwindSafe for StreamRetryPolicy
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.