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
impl StepOptions
Sourcepub fn new() -> StepOptions
pub fn new() -> StepOptions
Create a new StepOptions with no retries configured.
§Examples
use durable_lambda_core::types::StepOptions;
let opts = StepOptions::new();Sourcepub fn retries(self, count: i32) -> StepOptions
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);Sourcepub fn backoff_seconds(self, seconds: i32) -> StepOptions
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);Sourcepub fn get_retries(&self) -> Option<u32>
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));Sourcepub fn get_backoff_seconds(&self) -> Option<i32>
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));Sourcepub fn timeout_seconds(self, seconds: u64) -> StepOptions
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));Sourcepub fn retry_if<E, P>(self, predicate: P) -> StepOptions
pub fn retry_if<E, P>(self, predicate: P) -> StepOptions
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());Sourcepub fn get_timeout_seconds(&self) -> Option<u64>
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));Sourcepub fn get_retry_if(
&self,
) -> Option<&Arc<dyn Fn(&(dyn Any + 'static)) -> bool + Send + Sync>>
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
impl Clone for StepOptions
Source§fn clone(&self) -> StepOptions
fn clone(&self) -> StepOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StepOptions
impl Debug for StepOptions
Source§impl Default for StepOptions
impl Default for StepOptions
Source§fn default() -> StepOptions
fn default() -> StepOptions
Auto Trait Implementations§
impl Freeze for StepOptions
impl !RefUnwindSafe for StepOptions
impl Send for StepOptions
impl Sync for StepOptions
impl Unpin for StepOptions
impl UnsafeUnpin for StepOptions
impl !UnwindSafe for StepOptions
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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