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
  • 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 operation
      resultTypeToken - the type token for deserializing the result
      resultSerDes - the serializer/deserializer for the result
      durableContext - the parent context this operation belongs to
    • SerializableDurableOperation

      protected SerializableDurableOperation(OperationIdentifier operationIdentifier, TypeToken<T> resultTypeToken, SerDes resultSerDes, DurableContextImpl durableContext, BaseDurableOperation parentOperation)
  • Method Details

    • deserializeResult

      protected T deserializeResult(String result)
      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
    • serializeResult

      protected String serializeResult(T result)
      Serializes the result to a string.
      Parameters:
      result - the result to serialize
      Returns:
      the serialized string
    • serializeException

      protected software.amazon.awssdk.services.lambda.model.ErrorObject serializeException(Throwable throwable)
      Serializes a throwable into an ErrorObject for 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 an ErrorObject back 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

      public abstract T get()
      Description copied from interface: DurableFuture
      Blocks 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:
      get in interface DurableFuture<T>
      Returns:
      the operation result