Class SerializableDurableOperation<T>
java.lang.Object
software.amazon.lambda.durable.operation.BaseDurableOperation
software.amazon.lambda.durable.operation.SerializableDurableOperation<T>
- All Implemented Interfaces:
DurableFuture<T>
- Direct Known Subclasses:
CallbackOperation,ChildContextOperation,ConcurrencyOperation,InvokeOperation,StepOperation,WaitForConditionOperation
public abstract class SerializableDurableOperation<T>
extends BaseDurableOperation
implements DurableFuture<T>
Base class for all durable operations (STEP, WAIT, etc.).
Key methods:
execute()starts the operation (returns immediately)get()blocks until complete and returns the result
The separation allows:
- Starting multiple async operations quickly
- Blocking on results later when needed
- Proper thread coordination via future
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final record -
Field Summary
Fields inherited from class software.amazon.lambda.durable.operation.BaseDurableOperation
completionFuture, executionManager, isVirtual, parentOperation, replayCompletedOperation -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSerializableDurableOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext) Constructs a new durable operation.protectedSerializableDurableOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext, BaseDurableOperation parentOperation, boolean isVirtual) Constructs a new durable operation. -
Method Summary
Modifier and TypeMethodDescriptionprotected ThrowabledeserializeException(software.amazon.awssdk.services.lambda.model.ErrorObject errorObject) Deserializes anErrorObjectback into a throwable, reconstructing the original exception type and stack trace when possible.protected TdeserializeResult(String result) Deserializes a result string into the operation's result type.abstract Tget()Blocks until the operation completes and returns the result.protected SerializableDurableOperation.SerializedResult<T>serializeAndDeserializeResult(T result) Serializes the result and returns the value that should be exposed to callers.protected software.amazon.awssdk.services.lambda.model.ErrorObjectserializeException(Throwable throwable) Serializes a throwable into anErrorObjectfor checkpointing.Methods inherited from class software.amazon.lambda.durable.operation.BaseDurableOperation
deregisterActiveThread, execute, extractErrorFromOperation, fireOnOperationEnd, getChildOperations, getCompletionFuture, getContext, getCurrentThreadContext, getErrorObject, getName, getOperation, getOperationId, getRunningUserHandler, getSubType, getType, isOperationCompleted, markAlreadyCompleted, onCheckpointComplete, pollForOperationUpdates, pollForOperationUpdates, processCheckpointUpdate, registerActiveThread, replay, runUserFunction, runUserHandler, sendOperationUpdate, sendOperationUpdateAsync, start, terminateExecution, terminateExecutionWithIllegalDurableOperationException, validateReplay, waitForOperationCompletion
-
Constructor Details
-
SerializableDurableOperation
protected SerializableDurableOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext) Constructs a new durable operation.- Parameters:
operationIdentifier- the unique identifier for this operationresultTypeToken- the type token for deserializing the resultresultSerDes- the serializer/deserializer for the resultdurableContext- the parent context this operation belongs to
-
SerializableDurableOperation
protected SerializableDurableOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext, BaseDurableOperation parentOperation, boolean isVirtual) Constructs a new durable operation.- Parameters:
operationIdentifier- the unique identifier for this operationresultTypeToken- the type token for deserializing the resultresultSerDes- the serializer/deserializer for the resultdurableContext- the parent context this operation belongs toisVirtual- whether this is a virtual operation that should not be persistedparentOperation- the parent operation if this is a branch/iteration of a ConcurrencyOperation
-
-
Method Details
-
deserializeResult
Deserializes a result string into the operation's result type.- Parameters:
result- the serialized result string- Returns:
- the deserialized result
- Throws:
SerDesException- if deserialization fails
-
serializeAndDeserializeResult
Serializes the result and returns the value that should be exposed to callers.Use this for operations that cache a first-execution result instead of reading it back from checkpoint data. This keeps first execution consistent with replay when a SerDes normalizes or otherwise changes the value.
- Parameters:
result- the result to serialize- Returns:
- the serialized string and the deserialized result
-
serializeException
protected software.amazon.awssdk.services.lambda.model.ErrorObject serializeException(Throwable throwable) Serializes a throwable into anErrorObjectfor checkpointing.- Parameters:
throwable- the exception to serialize- Returns:
- the serialized error object
-
deserializeException
protected Throwable deserializeException(software.amazon.awssdk.services.lambda.model.ErrorObject errorObject) Deserializes anErrorObjectback into a throwable, reconstructing the original exception type and stack trace when possible. Falls back to null if the exception class is not found or deserialization fails.- Parameters:
errorObject- the serialized error object- Returns:
- the reconstructed throwable, or null if reconstruction is not possible
-
get
Description copied from interface:DurableFutureBlocks until the operation completes and returns the result.This delegates to operation.get() which handles: - Thread deregistration (allows suspension) - Thread reactivation (resumes execution) - Result retrieval
- Specified by:
getin interfaceDurableFuture<T>- Returns:
- the operation result
-