Class FileSystemSerDes

java.lang.Object
software.amazon.lambda.durable.serde.FileSystemSerDes
All Implemented Interfaces:
SerDes

public final class FileSystemSerDes extends Object implements SerDes
Stores operation payloads on a durable shared filesystem, retaining a small JSON envelope in checkpoints.

Configure this serializer on individual operations (for example, StepConfig.builder().serDes(...)). The global serializer also handles ordinary Lambda input/output without operation identity and is not supported. Existing serializers can be composed using FileSystemSerDes.Builder.delegate(SerDes).

Use a durable shared mount such as EFS. Lambda's ephemeral /tmp cannot survive replay in a different environment. A mount with delayed remote synchronization can lose payloads even after a successful local write. The mount and base directory must be controlled by the application, not writable by untrusted processes.

Each write creates an immutable file so retrying or polling never changes an earlier checkpoint's value. Files are not automatically deleted: retain them for the execution's full replay lifetime, then apply external cleanup. Configuration is immutable; custom delegates and preview generators must support concurrent calls.

  • Method Details

    • builder

      public static FileSystemSerDes.Builder builder(Path basePath)
      Creates a builder; defaults to ALWAYS, URI, and JacksonSerDes. No files are created until serialization.
    • serialize

      public String serialize(Object value)
      Description copied from interface: SerDes
      Serializes an object to a JSON string.
      Specified by:
      serialize in interface SerDes
      Parameters:
      value - the object to serialize
      Returns:
      the JSON string representation, or null if value is null
    • deserialize

      public <T> T deserialize(String data, TypeToken<T> typeToken)
      Description copied from interface: SerDes
      Deserializes a JSON string to an object of the specified generic type.

      This method supports complex generic types like List<MyObject> or Map<String, MyObject> that cannot be represented by a simple Class object.

      Usage example:

      
       List<String> items = serDes.deserialize(json, new TypeToken<List<String>>() {});
       
      Specified by:
      deserialize in interface SerDes
      Type Parameters:
      T - the target type
      Parameters:
      data - the JSON string to deserialize
      typeToken - the type token capturing the generic type information
      Returns:
      the deserialized object, or null if data is null
    • serialize

      public String serialize(Object value, SerDesContext context)
      Description copied from interface: SerDes
      Serializes an operation payload with its stable execution and entity identity.

      The default preserves existing implementations. Override this method when serialization needs external storage. References returned by such implementations must remain readable after later writes for the same entity.

      Specified by:
      serialize in interface SerDes
    • deserialize

      public <T> T deserialize(String data, TypeToken<T> typeToken, SerDesContext context)
      Description copied from interface: SerDes
      Deserializes an operation payload with its stable execution and entity identity.

      The default preserves existing implementations. The context identifies the consuming operation; externally produced callback and invoke results may have been serialized with a different context.

      Specified by:
      deserialize in interface SerDes