pub struct RetryPolicy { /* private fields */ }Expand description
Backoff policy for retrying transient RPC failures (Unavailable,
DeadlineExceeded, and Aborted, which map to ClientError::Transport,
plus ResourceExhausted, which maps to
Overloaded; a Cancelled RPC also maps to
Transport but is not retried).
Applies to enqueue, ack, nack, extend, and get-server-info — but not to
reserve, which is a long poll. The default policy
performs no retries (max_attempts == 1); opt in by building one up and
passing it to SeppClientBuilder::retry_policy.
Retried enqueues can duplicate jobs that carry no idempotency key. To limit
that hazard, an enqueue request in which any job lacks an
idempotency key is not
retried on the ambiguous-commit codes DeadlineExceeded and Aborted —
the server may have already committed the batch — while Unavailable and
ResourceExhausted (the request was rejected or never ran) stay retryable.
When every job in the request carries an idempotency key, the server
dedupes replays and the full transient set is retried.
use std::time::Duration;
use sepp_rs::client::RetryPolicy;
let policy = RetryPolicy::default()
.with_max_attempts(5)
.with_initial_backoff(Duration::from_millis(50))
.with_max_backoff(Duration::from_secs(5));Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn with_max_attempts(self, n: u32) -> Self
pub fn with_max_attempts(self, n: u32) -> Self
Sets the total number of attempts (including the first). Values below 1
are clamped to 1, so 1 means “no retries”.
Sourcepub fn with_initial_backoff(self, d: Duration) -> Self
pub fn with_initial_backoff(self, d: Duration) -> Self
Sets the backoff before the first retry. Each subsequent retry multiplies
this by with_multiplier, capped at
with_max_backoff.
Sourcepub fn with_max_backoff(self, d: Duration) -> Self
pub fn with_max_backoff(self, d: Duration) -> Self
Caps the backoff between retries.
Sourcepub fn with_multiplier(self, m: f64) -> Self
pub fn with_multiplier(self, m: f64) -> Self
Sets the exponential growth factor for the backoff. Values below 1.0 are clamped to 1.0 (constant backoff).
Sourcepub fn without_jitter(self) -> Self
pub fn without_jitter(self) -> Self
Disables jitter. By default each delay is randomized within
[0.5, 1.0) of its computed value to avoid thundering herds.
Sourcepub fn max_attempts(&self) -> u32
pub fn max_attempts(&self) -> u32
Returns the configured number of attempts.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
T in a tonic::Request