Skip to main content

StepOptions

Struct StepOptions 

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

Configure retry behavior for step operations.

Provide a builder-style API for configuring how step operations handle failures. By default, no retries are configured — failures are checkpointed immediately. When retries are configured, the SDK sends a RETRY checkpoint to the server, the function exits, and the server re-invokes the Lambda after the configured delay.

§Examples

use durable_lambda_core::types::StepOptions;

// No retries (default).
let opts = StepOptions::new();

// Retry up to 3 times with 5-second backoff.
let opts = StepOptions::new().retries(3).backoff_seconds(5);

// Per-step timeout of 10 seconds.
let opts = StepOptions::new().timeout_seconds(10);

// Only retry transient errors.
let opts = StepOptions::new()
    .retries(3)
    .retry_if(|e: &String| e.contains("transient"));

Implementations§

Source§

impl StepOptions

Source

pub fn new() -> StepOptions

Create a new StepOptions with no retries configured.

§Examples
use durable_lambda_core::types::StepOptions;

let opts = StepOptions::new();
Source

pub fn retries(self, count: i32) -> StepOptions

Set the maximum number of retry attempts on failure.

When a step fails and retries remain, the SDK sends a RETRY checkpoint and the server re-invokes the function after the backoff delay. Zero retries is valid and means the step will not be retried. Must be non-negative.

§Panics

Panics if count is negative.

§Examples
use durable_lambda_core::types::StepOptions;

let opts = StepOptions::new().retries(3);
Source

pub fn backoff_seconds(self, seconds: i32) -> StepOptions

Set the delay in seconds between retry attempts.

If not set, the server uses its default delay (typically 0 for immediate retry). Zero is valid and means immediate retry. Must be non-negative.

§Panics

Panics if seconds is negative.

§Examples
use durable_lambda_core::types::StepOptions;

let opts = StepOptions::new().retries(3).backoff_seconds(5);
Source

pub fn get_retries(&self) -> Option<u32>

Return the configured retry count, if any.

§Examples
use durable_lambda_core::types::StepOptions;

let opts = StepOptions::new();
assert_eq!(opts.get_retries(), None);

let opts = StepOptions::new().retries(3);
assert_eq!(opts.get_retries(), Some(3));
Source

pub fn get_backoff_seconds(&self) -> Option<i32>

Return the configured backoff delay in seconds, if any.

§Examples
use durable_lambda_core::types::StepOptions;

let opts = StepOptions::new();
assert_eq!(opts.get_backoff_seconds(), None);

let opts = StepOptions::new().backoff_seconds(5);
assert_eq!(opts.get_backoff_seconds(), Some(5));
Source

pub fn timeout_seconds(self, seconds: u64) -> StepOptions

Set the maximum execution time in seconds for this step.

If the step closure does not complete within this duration, the step returns DurableError::StepTimeout immediately and the spawned task is aborted. The timeout applies only to the closure execution, not to checkpoint I/O.

Must be a positive value (greater than zero).

§Panics

Panics if seconds is 0.

§Examples
use durable_lambda_core::types::StepOptions;

let opts = StepOptions::new().timeout_seconds(30);
assert_eq!(opts.get_timeout_seconds(), Some(30));
Source

pub fn retry_if<E, P>(self, predicate: P) -> StepOptions
where E: 'static, P: Fn(&E) -> bool + Send + Sync + 'static,

Set a predicate to determine whether a step error should be retried.

When a step fails, the predicate receives a reference to the error value (type-erased). If the predicate returns false, the step fails immediately without consuming the retry budget. If the predicate returns true (or if no predicate is set), retries proceed normally.

The type parameter E must match the error type used in step_with_options. If the downcast fails (wrong type), the predicate conservatively returns false.

The predicate is stored in an Arc so StepOptions remains Clone.

§Examples
use durable_lambda_core::types::StepOptions;

// Only retry errors that contain "transient".
let opts = StepOptions::new()
    .retries(3)
    .retry_if(|e: &String| e.contains("transient"));
assert!(opts.get_retry_if().is_some());
Source

pub fn get_timeout_seconds(&self) -> Option<u64>

Return the configured step timeout in seconds, if any.

§Examples
use durable_lambda_core::types::StepOptions;

let opts = StepOptions::new();
assert_eq!(opts.get_timeout_seconds(), None);

let opts = StepOptions::new().timeout_seconds(10);
assert_eq!(opts.get_timeout_seconds(), Some(10));
Source

pub fn get_retry_if( &self, ) -> Option<&Arc<dyn Fn(&(dyn Any + 'static)) -> bool + Send + Sync>>

Return a reference to the retry predicate, if one has been configured.

§Examples
use durable_lambda_core::types::StepOptions;

let opts = StepOptions::new();
assert!(opts.get_retry_if().is_none());

let opts = StepOptions::new().retry_if(|e: &String| e.contains("transient"));
assert!(opts.get_retry_if().is_some());

Trait Implementations§

Source§

impl Clone for StepOptions

Source§

fn clone(&self) -> StepOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StepOptions

Source§

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

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

impl Default for StepOptions

Source§

fn default() -> StepOptions

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

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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