Skip to content

Serializer

serializer

Payload serialization for the Durable Workflow worker protocol.

The server exposes a language-neutral payload envelope (see issue #164 and docs/configuration/worker-protocol.md in the docs repo). Every payload on the wire carries a payload_codec tag alongside its opaque blob.

Supported codecs:

  • "json" — the blob is a UTF-8 JSON document. Supported for decoding existing data only, not used for new workflows.
  • "avro" — the blob is a base64-encoded Avro generic-wrapper payload (see :mod:durable_workflow._avro). Default for all new v2 workflows.

encode

encode(value, codec=AVRO_CODEC)

Encode a Python value as a payload blob for codec.

Raises ValueError for unknown codecs and :class:~durable_workflow.errors.AvroNotInstalledError when the Avro runtime dependency is missing from a broken or partial installation.

envelope

envelope(value, codec=AVRO_CODEC)

Wrap a value in a {codec, blob} payload envelope.

decode_envelope

decode_envelope(value, codec=None)

Decode a value that may be a {codec, blob} envelope or a raw blob.

When value is an envelope, its inner codec takes precedence over the codec argument. When value is a raw blob, codec selects the decoder (defaulting to JSON).

decode

decode(blob, codec=None)

Decode a payload blob into a Python value.

Raises ValueError for unknown codecs or malformed blobs, and :class:~durable_workflow.errors.AvroNotInstalledError when the Avro runtime dependency is missing from a broken or partial installation.