Class LocalMemoryExecutionClient
java.lang.Object
software.amazon.lambda.durable.testing.LocalMemoryExecutionClient
- All Implemented Interfaces:
software.amazon.lambda.durable.client.DurableExecutionClient
public class LocalMemoryExecutionClient
extends Object
implements software.amazon.lambda.durable.client.DurableExecutionClient
In-memory implementation of
DurableExecutionClient for local testing. Stores operations and checkpoint state
in memory, simulating the durable execution backend without AWS infrastructure.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdvance all operations (simulates time passing for retries/waits).software.amazon.awssdk.services.lambda.model.CheckpointDurableExecutionResponsecheckpoint(String arn, String token, List<software.amazon.awssdk.services.lambda.model.OperationUpdate> updates) voidcompleteCallback(String callbackId, String result) Simulate external system completing callback successfully.voidcompleteChainedInvoke(String name, OperationResult result) Completes a chained invoke operation with the given result, simulating a child Lambda response.voidfailCallback(String callbackId, software.amazon.awssdk.services.lambda.model.ErrorObject error) Simulate external system failing callback.List<software.amazon.awssdk.services.lambda.model.Event>Get all events in order.List<software.amazon.awssdk.services.lambda.model.Operation>Returns all operations currently stored.getCallbackId(String operationName) Get callback ID for a named callback operation.List<software.amazon.awssdk.services.lambda.model.Event>getEventsForOperation(String operationId) Get events for a specific operation.software.amazon.awssdk.services.lambda.model.GetDurableExecutionStateResponsegetExecutionState(String arn, String checkpointToken, String marker) software.amazon.awssdk.services.lambda.model.OperationgetOperationByName(String name) Returns the operation with the given name, or null if not found.List<software.amazon.awssdk.services.lambda.model.OperationUpdate>Get all operation updates that have been sent to this client.voidreset()Clears all operations and events, resetting the client to its initial state.voidresetCheckpointToStarted(String stepName) Simulate checkpoint failure by forcing an operation into STARTED statevoidsimulateFireAndForgetCheckpointLoss(String stepName) Simulate fire-and-forget checkpoint loss by removing the operation entirelyvoidtimeoutCallback(String callbackId) Simulate callback timeout.<O> TestResult<O>toTestResult(software.amazon.lambda.durable.model.DurableExecutionOutput output) Build TestResult from current state.
-
Constructor Details
-
LocalMemoryExecutionClient
public LocalMemoryExecutionClient()
-
-
Method Details
-
checkpoint
public software.amazon.awssdk.services.lambda.model.CheckpointDurableExecutionResponse checkpoint(String arn, String token, List<software.amazon.awssdk.services.lambda.model.OperationUpdate> updates) - Specified by:
checkpointin interfacesoftware.amazon.lambda.durable.client.DurableExecutionClient
-
getExecutionState
public software.amazon.awssdk.services.lambda.model.GetDurableExecutionStateResponse getExecutionState(String arn, String checkpointToken, String marker) - Specified by:
getExecutionStatein interfacesoftware.amazon.lambda.durable.client.DurableExecutionClient
-
getOperationUpdates
Get all operation updates that have been sent to this client. Useful for testing and verification. -
getAllEvents
Get all events in order. -
getEventsForOperation
public List<software.amazon.awssdk.services.lambda.model.Event> getEventsForOperation(String operationId) Get events for a specific operation. -
advanceReadyOperations
public boolean advanceReadyOperations()Advance all operations (simulates time passing for retries/waits).- Returns:
- true if any operations were advanced, false otherwise
-
completeChainedInvoke
Completes a chained invoke operation with the given result, simulating a child Lambda response. -
getOperationByName
Returns the operation with the given name, or null if not found. -
getAllOperations
Returns all operations currently stored. -
reset
public void reset()Clears all operations and events, resetting the client to its initial state. -
toTestResult
public <O> TestResult<O> toTestResult(software.amazon.lambda.durable.model.DurableExecutionOutput output) Build TestResult from current state. -
resetCheckpointToStarted
Simulate checkpoint failure by forcing an operation into STARTED state -
simulateFireAndForgetCheckpointLoss
Simulate fire-and-forget checkpoint loss by removing the operation entirely -
getCallbackId
Get callback ID for a named callback operation. -
completeCallback
Simulate external system completing callback successfully. -
failCallback
public void failCallback(String callbackId, software.amazon.awssdk.services.lambda.model.ErrorObject error) Simulate external system failing callback. -
timeoutCallback
Simulate callback timeout.
-