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
impl ExecutionState
Sourcepub fn new(
durable_execution_arn: impl Into<String>,
checkpoint_token: impl Into<String>,
initial_state: InitialExecutionState,
service_client: SharedDurableServiceClient,
) -> Self
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 executioncheckpoint_token- The initial checkpoint tokeninitial_state- The initial execution state with operationsservice_client- The service client for Lambda communication
Sourcepub 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
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.
Sourcepub 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)
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.
Sourcepub 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)
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.
Sourcepub fn durable_execution_arn(&self) -> &str
pub fn durable_execution_arn(&self) -> &str
Returns the durable execution ARN.
Sourcepub fn durable_execution_arn_typed(&self) -> ExecutionArn
pub fn durable_execution_arn_typed(&self) -> ExecutionArn
Returns the durable execution ARN as an ExecutionArn newtype.
Sourcepub async fn checkpoint_token(&self) -> String
pub async fn checkpoint_token(&self) -> String
Returns the current checkpoint token.
Sourcepub async fn set_checkpoint_token(&self, token: impl Into<String>)
pub async fn set_checkpoint_token(&self, token: impl Into<String>)
Updates the checkpoint token after a successful checkpoint.
Sourcepub fn replay_status(&self) -> ReplayStatus
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
Sourcepub fn checkpointing_mode(&self) -> CheckpointingMode
pub fn checkpointing_mode(&self) -> CheckpointingMode
Returns the current checkpointing mode.
Sourcepub fn is_eager_checkpointing(&self) -> bool
pub fn is_eager_checkpointing(&self) -> bool
Returns true if eager checkpointing mode is enabled.
Sourcepub fn is_batched_checkpointing(&self) -> bool
pub fn is_batched_checkpointing(&self) -> bool
Returns true if batched checkpointing mode is enabled.
Sourcepub fn is_optimistic_checkpointing(&self) -> bool
pub fn is_optimistic_checkpointing(&self) -> bool
Returns true if optimistic checkpointing mode is enabled.
Sourcepub fn execution_operation(&self) -> Option<&Operation>
pub fn execution_operation(&self) -> Option<&Operation>
Returns a reference to the EXECUTION operation if it exists.
Sourcepub fn get_original_input_raw(&self) -> Option<&str>
pub fn get_original_input_raw(&self) -> Option<&str>
Returns the original user input from the EXECUTION operation.
Sourcepub fn execution_operation_id(&self) -> Option<&str>
pub fn execution_operation_id(&self) -> Option<&str>
Returns the EXECUTION operation’s ID if it exists.
Sourcepub async fn complete_execution_success(
&self,
result: Option<String>,
) -> Result<(), DurableError>
pub async fn complete_execution_success( &self, result: Option<String>, ) -> Result<(), DurableError>
Completes the execution with a successful result via checkpointing.
Sourcepub async fn complete_execution_failure(
&self,
error: ErrorObject,
) -> Result<(), DurableError>
pub async fn complete_execution_failure( &self, error: ErrorObject, ) -> Result<(), DurableError>
Completes the execution with a failure via checkpointing.
Sourcepub async fn get_checkpoint_result(
&self,
operation_id: &str,
) -> CheckpointedResult
pub async fn get_checkpoint_result( &self, operation_id: &str, ) -> CheckpointedResult
Gets the checkpoint result for an operation.
Sourcepub async fn track_replay(&self, operation_id: &str)
pub async fn track_replay(&self, operation_id: &str)
Tracks that an operation has been replayed.
Sourcepub async fn load_more_operations(&self) -> Result<bool, DurableError>
pub async fn load_more_operations(&self) -> Result<bool, DurableError>
Loads additional operations from the service for pagination.
Sourcepub async fn load_all_operations(&self) -> Result<(), DurableError>
pub async fn load_all_operations(&self) -> Result<(), DurableError>
Loads all remaining operations from the service.
Sourcepub async fn has_more_operations(&self) -> bool
pub async fn has_more_operations(&self) -> bool
Returns true if there are more operations to load.
Sourcepub async fn operation_count(&self) -> usize
pub async fn operation_count(&self) -> usize
Returns the number of loaded operations.
Sourcepub fn service_client(&self) -> &SharedDurableServiceClient
pub fn service_client(&self) -> &SharedDurableServiceClient
Returns a reference to the service client.
Sourcepub async fn add_operation(&self, operation: Operation)
pub async fn add_operation(&self, operation: Operation)
Adds an operation to the local cache.
Sourcepub async fn update_operation(
&self,
operation_id: &str,
update_fn: impl FnOnce(&mut Operation),
)
pub async fn update_operation( &self, operation_id: &str, update_fn: impl FnOnce(&mut Operation), )
Updates an existing operation in the local cache.
Sourcepub async fn has_operation(&self, operation_id: &str) -> bool
pub async fn has_operation(&self, operation_id: &str) -> bool
Checks if an operation exists in the local cache.
Sourcepub async fn get_operation(&self, operation_id: &str) -> Option<Operation>
pub async fn get_operation(&self, operation_id: &str) -> Option<Operation>
Gets a clone of an operation from the local cache.
Sourcepub async fn mark_parent_done(&self, parent_id: &str)
pub async fn mark_parent_done(&self, parent_id: &str)
Marks a parent operation as done.
Sourcepub async fn is_parent_done(&self, parent_id: &str) -> bool
pub async fn is_parent_done(&self, parent_id: &str) -> bool
Checks if a parent operation has been marked as done.
Sourcepub async fn is_orphaned(&self, parent_id: Option<&str>) -> bool
pub async fn is_orphaned(&self, parent_id: Option<&str>) -> bool
Checks if an operation would be orphaned.
Sourcepub async fn create_checkpoint(
&self,
operation: OperationUpdate,
is_sync: bool,
) -> Result<(), DurableError>
pub async fn create_checkpoint( &self, operation: OperationUpdate, is_sync: bool, ) -> Result<(), DurableError>
Creates a checkpoint for an operation.
Sourcepub async fn create_checkpoint_with_response(
&self,
operation: OperationUpdate,
) -> Result<CheckpointResponse, DurableError>
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.
Sourcepub async fn checkpoint_sync(
&self,
operation: OperationUpdate,
) -> Result<(), DurableError>
pub async fn checkpoint_sync( &self, operation: OperationUpdate, ) -> Result<(), DurableError>
Creates a synchronous checkpoint (waits for confirmation).
Sourcepub async fn checkpoint_async(
&self,
operation: OperationUpdate,
) -> Result<(), DurableError>
pub async fn checkpoint_async( &self, operation: OperationUpdate, ) -> Result<(), DurableError>
Creates an asynchronous checkpoint (fire-and-forget).
Sourcepub async fn checkpoint_optimal(
&self,
operation: OperationUpdate,
prefer_sync: bool,
) -> Result<(), DurableError>
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.
Sourcepub fn should_use_async_checkpoint(&self) -> bool
pub fn should_use_async_checkpoint(&self) -> bool
Returns whether async checkpointing is recommended for the current mode.
Sourcepub fn prioritizes_performance(&self) -> bool
pub fn prioritizes_performance(&self) -> bool
Returns whether the current mode prioritizes performance over durability.
Sourcepub fn prioritizes_durability(&self) -> bool
pub fn prioritizes_durability(&self) -> bool
Returns whether the current mode prioritizes durability over performance.
Returns a reference to the shared checkpoint token.
Sourcepub fn has_checkpoint_sender(&self) -> bool
pub fn has_checkpoint_sender(&self) -> bool
Returns true if this ExecutionState has a checkpoint sender configured.
Sourcepub async fn load_child_operations(
&self,
parent_id: &str,
) -> Result<Vec<Operation>, DurableError>
pub async fn load_child_operations( &self, parent_id: &str, ) -> Result<Vec<Operation>, DurableError>
Loads child operations for a specific parent operation.
Sourcepub async fn get_child_operations(&self, parent_id: &str) -> Vec<Operation>
pub async fn get_child_operations(&self, parent_id: &str) -> Vec<Operation>
Gets all child operations for a specific parent from the local cache.
Sourcepub async fn has_replay_children(&self, operation_id: &str) -> bool
pub async fn has_replay_children(&self, operation_id: &str) -> bool
Checks if a CONTEXT operation has ReplayChildren enabled.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ExecutionState
impl !RefUnwindSafe for ExecutionState
impl Send for ExecutionState
impl Sync for ExecutionState
impl Unpin for ExecutionState
impl UnsafeUnpin for ExecutionState
impl !UnwindSafe for ExecutionState
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> 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