pub struct RetryPolicy { /* private fields */ }Expand description
Retry policy covering attempts, backoff, and retryable failure classes.
See also:
examples/resilience_controls.rsexamples/retry_classifier.rs
§Example
use std::time::Duration;
use reqx::prelude::RetryPolicy;
use reqx::TransportErrorKind;
let policy = RetryPolicy::standard()
.max_attempts(4)
.base_backoff(Duration::from_millis(100))
.max_backoff(Duration::from_secs(1))
.transport_retry_window(TransportErrorKind::Connect, 2);
let _ = policy;Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn max_attempts(self, max_attempts: usize) -> Self
pub fn max_attempts(self, max_attempts: usize) -> Self
Sets the maximum number of attempts, including the first try.
Sourcepub fn base_backoff(self, base_backoff: Duration) -> Self
pub fn base_backoff(self, base_backoff: Duration) -> Self
Sets the base exponential backoff delay.
Sourcepub fn max_backoff(self, max_backoff: Duration) -> Self
pub fn max_backoff(self, max_backoff: Duration) -> Self
Sets the maximum backoff delay.
Sourcepub fn jitter_ratio(self, jitter_ratio: f64) -> Self
pub fn jitter_ratio(self, jitter_ratio: f64) -> Self
Sets the random jitter ratio applied to computed backoffs.
Sourcepub fn retryable_status_codes(
self,
codes: impl IntoIterator<Item = u16>,
) -> Self
pub fn retryable_status_codes( self, codes: impl IntoIterator<Item = u16>, ) -> Self
Replaces the set of retryable HTTP status codes.
Sourcepub fn retryable_transport_error_kinds(
self,
kinds: impl IntoIterator<Item = TransportErrorKind>,
) -> Self
pub fn retryable_transport_error_kinds( self, kinds: impl IntoIterator<Item = TransportErrorKind>, ) -> Self
Replaces the set of retryable transport error kinds.
Sourcepub fn retryable_timeout_phases(
self,
phases: impl IntoIterator<Item = TimeoutPhase>,
) -> Self
pub fn retryable_timeout_phases( self, phases: impl IntoIterator<Item = TimeoutPhase>, ) -> Self
Replaces the set of retryable timeout phases.
Sourcepub fn retry_on_response_body_read_error(self, retry: bool) -> Self
pub fn retry_on_response_body_read_error(self, retry: bool) -> Self
Enables or disables retries after response body read failures.
Sourcepub fn status_retry_window(self, status: u16, max_attempts: usize) -> Self
pub fn status_retry_window(self, status: u16, max_attempts: usize) -> Self
Sets a per-status retry window measured in maximum attempts.
Sourcepub fn transport_retry_window(
self,
kind: TransportErrorKind,
max_attempts: usize,
) -> Self
pub fn transport_retry_window( self, kind: TransportErrorKind, max_attempts: usize, ) -> Self
Sets a per-transport-kind retry window measured in maximum attempts.
Sourcepub fn timeout_retry_window(
self,
phase: TimeoutPhase,
max_attempts: usize,
) -> Self
pub fn timeout_retry_window( self, phase: TimeoutPhase, max_attempts: usize, ) -> Self
Sets a per-timeout-phase retry window measured in maximum attempts.
Sourcepub fn response_body_read_retry_window(self, max_attempts: usize) -> Self
pub fn response_body_read_retry_window(self, max_attempts: usize) -> Self
Sets the retry window for response body read failures.
Sourcepub fn retry_classifier(
self,
retry_classifier: Arc<dyn RetryClassifier>,
) -> Self
pub fn retry_classifier( self, retry_classifier: Arc<dyn RetryClassifier>, ) -> Self
Sets a custom classifier that can override the built-in retry rules.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more