Skip to main content

RetryPolicy

Struct RetryPolicy 

Source
pub struct RetryPolicy { /* private fields */ }
Expand description

Overrides Dex retry timing for a Flow, wait_for, or execute operation.

Unset fields use server defaults. Intervals and total duration use Duration; maximum attempts counts the initial attempt. A zero maximum attempts value uses the server behavior.

Step retries default to a one-second initial interval, a multiplier of 2, a 100-second maximum interval, unlimited attempts, and four hours of total duration. Zero values select those defaults. A maximum of one disables retries. Non-retryable handler failures do not retry.

Changed in 1.35.0: a Step’s total duration starts at its first hand-out to a Worker. It only gates scheduling another retry after failure; it never interrupts a running attempt. Method and heartbeat timeouts still apply to that attempt. Initial queue and lock waits do not consume the budget. Later backoff and queue waits do. A scheduled retry can start after the budget expires. Gracefully returning attempt one resets the budget’s start only when no execution of that attempt may have run.

Use this policy for Step methods. The Server does not support whole-Flow retry. It rejects crate::StartFlowOptions::retry_policy with INVALID_ARGUMENT and rejects a SubFlow that sets crate::SubFlowOptions::retry_policy as invalid input. Use Step retry policies instead. Duration values must fit signed 32-bit whole seconds when submitted. Builders take ownership and return the updated policy; validation occurs when the options are mapped for a request.

§Examples

use dex_sdk::RetryPolicy;
use std::time::Duration;

let retry = RetryPolicy::new()
    .initial_interval(Duration::from_secs(1))
    .backoff_coefficient(2.0)
    .maximum_interval(Duration::from_secs(30))
    .maximum_attempts(5);

Implementations§

Source§

impl RetryPolicy

Source

pub fn new() -> Self

Creates an empty policy that preserves every server default.

Source

pub fn initial_interval(self, value: Duration) -> Self

Sets the delay before the first retry.

Zero uses one second. The value must fit signed 32-bit whole seconds.

Source

pub fn backoff_coefficient(self, value: f64) -> Self

Sets the multiplier applied to each successive retry interval.

Zero uses 2. The retry delay grows by this multiplier until the maximum interval.

Source

pub fn maximum_interval(self, value: Duration) -> Self

Caps the delay between retries.

Zero uses 100 seconds. The value must fit signed 32-bit whole seconds.

Source

pub fn maximum_attempts(self, value: u32) -> Self

Sets the total attempt limit, including the initial attempt.

Zero allows unlimited attempts within the total-duration budget for Steps. One disables retries. Values above the signed 32-bit maximum fail when the policy is submitted.

Source

pub fn total_duration(self, value: Duration) -> Self

Sets the elapsed-time budget used to decide whether to retry a failed Step attempt.

For Steps, time starts when Dex first hands the Step to a Worker. Dex checks this budget only after an attempt fails; expiration never ends a running attempt. Unset uses the Server default of four hours. Zero also selects that default. value uses Duration and is serialized in seconds; invalid durations fail when the policy is submitted. Returns this policy with the budget applied.

Changed in 1.35.0: queueing before the first hand-out is excluded, and this budget no longer shortens a running attempt’s method timeout. See RetryPolicy for retry queueing.

use dex_sdk::RetryPolicy;
use std::time::Duration;
let retry = RetryPolicy::new().total_duration(Duration::from_secs(60));

Trait Implementations§

Source§

impl Clone for RetryPolicy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RetryPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RetryPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for RetryPolicy

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RetryPolicy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more