Skip to main content

ExecutionState

Struct ExecutionState 

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

Manages the execution state for a durable execution.

This struct tracks all checkpointed operations, handles replay logic, and manages communication with the Lambda durable execution service.

Implementations§

Source§

impl ExecutionState

Source

pub fn new( durable_execution_arn: impl Into<String>, checkpoint_token: impl Into<String>, initial_state: InitialExecutionState, service_client: SharedDurableServiceClient, ) -> Self

Creates a new ExecutionState from the Lambda invocation input.

§Arguments
  • durable_execution_arn - The ARN of the durable execution
  • checkpoint_token - The initial checkpoint token
  • initial_state - The initial execution state with operations
  • service_client - The service client for Lambda communication
Source

pub fn with_checkpointing_mode( durable_execution_arn: impl Into<String>, checkpoint_token: impl Into<String>, initial_state: InitialExecutionState, service_client: SharedDurableServiceClient, checkpointing_mode: CheckpointingMode, ) -> Self

Creates a new ExecutionState with a specific checkpointing mode.

Source

pub fn with_batcher( durable_execution_arn: impl Into<String>, checkpoint_token: impl Into<String>, initial_state: InitialExecutionState, service_client: SharedDurableServiceClient, batcher_config: CheckpointBatcherConfig, queue_buffer_size: usize, ) -> (Self, CheckpointBatcher)

Creates a new ExecutionState with a checkpoint batcher.

This method sets up the checkpoint queue and batcher for efficient batched checkpointing. Returns the ExecutionState and a handle to the batcher that should be run in a background task.

Source

pub fn with_batcher_and_mode( durable_execution_arn: impl Into<String>, checkpoint_token: impl Into<String>, initial_state: InitialExecutionState, service_client: SharedDurableServiceClient, batcher_config: CheckpointBatcherConfig, queue_buffer_size: usize, checkpointing_mode: CheckpointingMode, ) -> (Self, CheckpointBatcher)

Creates a new ExecutionState with a checkpoint batcher and specific checkpointing mode.

Source

pub fn durable_execution_arn(&self) -> &str

Returns the durable execution ARN.

Source

pub fn durable_execution_arn_typed(&self) -> ExecutionArn

Returns the durable execution ARN as an ExecutionArn newtype.

Source

pub async fn checkpoint_token(&self) -> String

Returns the current checkpoint token.

Source

pub async fn set_checkpoint_token(&self, token: impl Into<String>)

Updates the checkpoint token after a successful checkpoint.

Source

pub fn replay_status(&self) -> ReplayStatus

Returns the current replay status.

§Memory Ordering

Uses Ordering::Acquire to ensure that when we read the replay status, we also see all the operations that were replayed before the status was set to New. This creates a happens-before relationship with the Release store in track_replay.

Requirements: 4.2, 4.3, 4.6

Source

pub fn is_replay(&self) -> bool

Returns true if currently in replay mode.

Source

pub fn is_new(&self) -> bool

Returns true if executing new operations.

Source

pub fn checkpointing_mode(&self) -> CheckpointingMode

Returns the current checkpointing mode.

Source

pub fn is_eager_checkpointing(&self) -> bool

Returns true if eager checkpointing mode is enabled.

Source

pub fn is_batched_checkpointing(&self) -> bool

Returns true if batched checkpointing mode is enabled.

Source

pub fn is_optimistic_checkpointing(&self) -> bool

Returns true if optimistic checkpointing mode is enabled.

Source

pub fn execution_operation(&self) -> Option<&Operation>

Returns a reference to the EXECUTION operation if it exists.

Source

pub fn get_original_input_raw(&self) -> Option<&str>

Returns the original user input from the EXECUTION operation.

Source

pub fn execution_operation_id(&self) -> Option<&str>

Returns the EXECUTION operation’s ID if it exists.

Source

pub async fn complete_execution_success( &self, result: Option<String>, ) -> Result<(), DurableError>

Completes the execution with a successful result via checkpointing.

Source

pub async fn complete_execution_failure( &self, error: ErrorObject, ) -> Result<(), DurableError>

Completes the execution with a failure via checkpointing.

Source

pub async fn get_checkpoint_result( &self, operation_id: &str, ) -> CheckpointedResult

Gets the checkpoint result for an operation.

Source

pub async fn track_replay(&self, operation_id: &str)

Tracks that an operation has been replayed.

Source

pub async fn load_more_operations(&self) -> Result<bool, DurableError>

Loads additional operations from the service for pagination.

Source

pub async fn load_all_operations(&self) -> Result<(), DurableError>

Loads all remaining operations from the service.

Source

pub async fn has_more_operations(&self) -> bool

Returns true if there are more operations to load.

Source

pub async fn operation_count(&self) -> usize

Returns the number of loaded operations.

Source

pub fn service_client(&self) -> &SharedDurableServiceClient

Returns a reference to the service client.

Source

pub async fn add_operation(&self, operation: Operation)

Adds an operation to the local cache.

Source

pub async fn update_operation( &self, operation_id: &str, update_fn: impl FnOnce(&mut Operation), )

Updates an existing operation in the local cache.

Source

pub async fn has_operation(&self, operation_id: &str) -> bool

Checks if an operation exists in the local cache.

Source

pub async fn get_operation(&self, operation_id: &str) -> Option<Operation>

Gets a clone of an operation from the local cache.

Source

pub async fn mark_parent_done(&self, parent_id: &str)

Marks a parent operation as done.

Source

pub async fn is_parent_done(&self, parent_id: &str) -> bool

Checks if a parent operation has been marked as done.

Source

pub async fn is_orphaned(&self, parent_id: Option<&str>) -> bool

Checks if an operation would be orphaned.

Source

pub async fn create_checkpoint( &self, operation: OperationUpdate, is_sync: bool, ) -> Result<(), DurableError>

Creates a checkpoint for an operation.

Source

pub async fn create_checkpoint_with_response( &self, operation: OperationUpdate, ) -> Result<CheckpointResponse, DurableError>

Creates a checkpoint and returns the full response including NewExecutionState. This is useful for operations like CALLBACK that need service-generated values.

Source

pub async fn checkpoint_sync( &self, operation: OperationUpdate, ) -> Result<(), DurableError>

Creates a synchronous checkpoint (waits for confirmation).

Source

pub async fn checkpoint_async( &self, operation: OperationUpdate, ) -> Result<(), DurableError>

Creates an asynchronous checkpoint (fire-and-forget).

Source

pub async fn checkpoint_optimal( &self, operation: OperationUpdate, prefer_sync: bool, ) -> Result<(), DurableError>

Creates a checkpoint using the optimal sync behavior for the current mode.

Source

pub fn should_use_async_checkpoint(&self) -> bool

Returns whether async checkpointing is recommended for the current mode.

Source

pub fn prioritizes_performance(&self) -> bool

Returns whether the current mode prioritizes performance over durability.

Source

pub fn prioritizes_durability(&self) -> bool

Returns whether the current mode prioritizes durability over performance.

Source

pub fn shared_checkpoint_token(&self) -> Arc<RwLock<String>>

Returns a reference to the shared checkpoint token.

Source

pub fn has_checkpoint_sender(&self) -> bool

Returns true if this ExecutionState has a checkpoint sender configured.

Source

pub async fn load_child_operations( &self, parent_id: &str, ) -> Result<Vec<Operation>, DurableError>

Loads child operations for a specific parent operation.

Source

pub async fn get_child_operations(&self, parent_id: &str) -> Vec<Operation>

Gets all child operations for a specific parent from the local cache.

Source

pub async fn has_replay_children(&self, operation_id: &str) -> bool

Checks if a CONTEXT operation has ReplayChildren enabled.

Trait Implementations§

Source§

impl Debug for ExecutionState

Source§

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

Formats the value using the given formatter. 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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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, 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