Belay.Codec (Belay v2.0.0)

Copy Markdown View Source

The cross-language value envelope for step values and job results (SCHEMA.md, "Value encoding").

Binary values in belay_steps.value and belay_jobs.result are one of:

  • Erlang external term format — first byte 131; written by the Elixir SDK (:erlang.term_to_binary/1), which preserves rich terms.
  • UTF-8 JSON — anything else; the required encoding for non-Elixir SDKs. JSON never begins with byte 131, so the discriminator is exact.

Every SDK must read both; each SDK writes its native side. Reserved step values ($sleep:*, $spawn:*) are SDK-internal — treat foreign ones as opaque.

Summary

Functions

Decode a stored value: ETF or JSON by the leading-byte discriminator.

Encode a term for storage (Elixir writes ETF).

Functions

decode(binary)

@spec decode(binary() | nil) :: term()

Decode a stored value: ETF or JSON by the leading-byte discriminator.

encode(term)

@spec encode(term()) :: binary()

Encode a term for storage (Elixir writes ETF).