pub struct RetryClient { /* private fields */ }Expand description
HTTP client with sophisticated retry logic and exponential backoff
Implementations§
Source§impl RetryClient
impl RetryClient
Sourcepub fn new(config: RetryConfig) -> Self
pub fn new(config: RetryConfig) -> Self
Creates a new RetryClient with the given configuration
Sourcepub fn with_default_config() -> Self
pub fn with_default_config() -> Self
Creates a new RetryClient with default configuration
Sourcepub async fn execute_with_retry<F>(
&self,
request_builder: F,
) -> Result<Response, TokenError>
pub async fn execute_with_retry<F>( &self, request_builder: F, ) -> Result<Response, TokenError>
Executes an HTTP request with retry logic and exponential backoff
§Arguments
request_builder- A function that creates the request builder
§Returns
The response if successful, or an error after all retries are exhausted
§Errors
Returns TokenError::Timeout if the request times out
Returns TokenError::RateLimited if rate limited and retries are exhausted
Returns TokenError::ObtainFailed if all retry attempts fail
Sourcepub fn calculate_backoff_delay(&self, attempt: u32) -> StdDuration
pub fn calculate_backoff_delay(&self, attempt: u32) -> StdDuration
Calculates the delay for exponential backoff with jitter
Uses the formula: min(base_delay * 2^(attempt-1) + jitter, max_delay)
where jitter is a random value between 0 and base_delay/2
Sourcepub const fn config(&self) -> &RetryConfig
pub const fn config(&self) -> &RetryConfig
Gets the retry configuration
Trait Implementations§
Source§impl Clone for RetryClient
impl Clone for RetryClient
Source§fn clone(&self) -> RetryClient
fn clone(&self) -> RetryClient
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 moreAuto Trait Implementations§
impl !RefUnwindSafe for RetryClient
impl !UnwindSafe for RetryClient
impl Freeze for RetryClient
impl Send for RetryClient
impl Sync for RetryClient
impl Unpin for RetryClient
impl UnsafeUnpin for RetryClient
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