pub struct RetryPolicy {
pub max_retries: u32,
pub backoff: BackoffStrategy,
pub jitter: bool,
pub jitter_percent: u32,
pub retryable_codes: Vec<String>,
}Expand description
Configuration for retry behavior.
Fields§
§max_retries: u32Maximum number of retry attempts (0 = no retries).
backoff: BackoffStrategyBackoff strategy.
jitter: boolWhether to add jitter to computed delays.
jitter_percent: u32Maximum jitter percentage (0..100).
retryable_codes: Vec<String>Set of error codes that are retryable (empty = all errors are retryable).
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn new(max_retries: u32) -> Self
pub fn new(max_retries: u32) -> Self
Create a new retry policy with exponential backoff defaults.
Sourcepub fn with_backoff(self, backoff: BackoffStrategy) -> Self
pub fn with_backoff(self, backoff: BackoffStrategy) -> Self
Set the backoff strategy.
Sourcepub fn with_jitter(self, percent: u32) -> Self
pub fn with_jitter(self, percent: u32) -> Self
Enable jitter with the given percentage.
Sourcepub fn add_retryable_code(&mut self, code: &str)
pub fn add_retryable_code(&mut self, code: &str)
Add a retryable error code.
Sourcepub fn is_retryable(&self, code: &str) -> bool
pub fn is_retryable(&self, code: &str) -> bool
Check if an error code is retryable.
Sourcepub fn compute_delay(&self, attempt: u32) -> Duration
pub fn compute_delay(&self, attempt: u32) -> Duration
Compute the delay for the given attempt number (0-based).
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
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 moreSource§impl Debug for RetryPolicy
impl Debug for RetryPolicy
Auto Trait Implementations§
impl Freeze for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin for RetryPolicy
impl UnwindSafe for RetryPolicy
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request