StatifierOban.OpaqueTerm (StatifierOban v0.1.1)

Copy Markdown View Source

Tagged :erlang.term_to_binary/1 payloads for the host-opaque fields a job's args carry.

Oban args live as JSON, and some Statifier effect fields (data, caller_context, an invoke's params and content) are arbitrary terms with no JSON shape - so they ride as Base64-encoded external term format under a single tag key, and come back byte-identical. nil stays nil, so the common case costs nothing and stays readable in the row.

Decoding uses :safe, so a payload naming an atom the reading node has never seen decodes to a typed error rather than minting atoms. Both job wire modules (StatifierOban.Timer.JobArgs, StatifierOban.Invoke.JobArgs) share this one encoding, which is what keeps their rows mutually readable during an incident.

Summary

Types

Why a stored payload could not be decoded.

Functions

Decodes the tagged payload stored under field in args.

Encodes term as a tagged payload map, or nil for nil.

Types

decode_error()

@type decode_error() :: {:invalid_field, String.t(), term()}

Why a stored payload could not be decoded.

Functions

decode_field(args, field)

@spec decode_field(map(), String.t()) :: {:ok, term()} | {:error, decode_error()}

Decodes the tagged payload stored under field in args.

A missing or nil field decodes to {:ok, nil} - the exact inverse of encode/1's nil arm. Anything that is neither nil nor a well-formed tagged payload is a typed error about the row, returned as data rather than raised: the caller (a worker at its boundary) decides what a corrupt row costs.

encode(term)

@spec encode(term()) :: nil | %{required(String.t()) => String.t()}

Encodes term as a tagged payload map, or nil for nil.