pub struct ReconnectConfig {
pub base_delay: Duration,
pub max_delay: Duration,
}Expand description
Configures exponential reconnect backoff.
Fields§
§base_delay: DurationInitial retry delay before exponential growth is applied.
max_delay: DurationMaximum delay used for the exponential component before jitter is added.
Implementations§
Source§impl ReconnectConfig
impl ReconnectConfig
Sourcepub const fn new(base_delay: Duration, max_delay: Duration) -> Self
pub const fn new(base_delay: Duration, max_delay: Duration) -> Self
Creates a reconnect configuration from base and maximum delays.
Sourcepub fn capped_delay(self, attempt: u32) -> Duration
pub fn capped_delay(self, attempt: u32) -> Duration
Computes min(base_delay * 2^attempt, max_delay) before jitter.
Sourcepub fn retry_delay<J>(
self,
attempt: u32,
jitter: &mut J,
) -> Result<Duration, SdkError>where
J: ReconnectJitter + ?Sized,
pub fn retry_delay<J>(
self,
attempt: u32,
jitter: &mut J,
) -> Result<Duration, SdkError>where
J: ReconnectJitter + ?Sized,
Sourcepub fn retry_delay_with_jitter(
self,
attempt: u32,
jitter: Duration,
) -> Result<Duration, SdkError>
pub fn retry_delay_with_jitter( self, attempt: u32, jitter: Duration, ) -> Result<Duration, SdkError>
Computes the retry delay for an attempt using a precomputed jitter value.
This helper is useful for deterministic tests and for transport layers that produce randomness externally. The jitter value must be between zero and 50% of the capped exponential delay.
§Errors
Returns SdkError if jitter is greater than 50% of the capped delay.
Trait Implementations§
Source§impl Clone for ReconnectConfig
impl Clone for ReconnectConfig
Source§fn clone(&self) -> ReconnectConfig
fn clone(&self) -> ReconnectConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ReconnectConfig
Source§impl Debug for ReconnectConfig
impl Debug for ReconnectConfig
Source§impl Default for ReconnectConfig
impl Default for ReconnectConfig
impl Eq for ReconnectConfig
Source§impl PartialEq for ReconnectConfig
impl PartialEq for ReconnectConfig
Source§fn eq(&self, other: &ReconnectConfig) -> bool
fn eq(&self, other: &ReconnectConfig) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ReconnectConfig
Auto Trait Implementations§
impl Freeze for ReconnectConfig
impl RefUnwindSafe for ReconnectConfig
impl Send for ReconnectConfig
impl Sync for ReconnectConfig
impl Unpin for ReconnectConfig
impl UnsafeUnpin for ReconnectConfig
impl UnwindSafe for ReconnectConfig
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
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.