Framework envelope shapes (implementation.md §8). Three shapes, built and parsed only here, versioned by a protocol integer:
{:fief, 1, :msg, epoch, vnode, payload, from | nil}
{:fief, 1, :moved, epoch, delta}
{:fief, 1, :peer, session, payload}Payloads are opaque to the framework. The epoch in :msg is the sender's
cached epoch — a fencing token for diagnostics, not an equality check.
Summary
Functions
Decode an inbound term. Non-fief terms and unsupported protocol versions are distinguished so receivers can drop vs. log-and-drop.
Build a :moved envelope carrying a routing delta.
Build a :msg envelope.
Build a :peer envelope; delivered only on session match (framework-enforced).
The wire protocol version this build speaks.
Types
@type envelope() :: tuple()
@type epoch() :: non_neg_integer()
@type vnode_id() :: non_neg_integer()
Functions
Decode an inbound term. Non-fief terms and unsupported protocol versions are distinguished so receivers can drop vs. log-and-drop.
iex> Fief.Wire.msg(7, 3, :ping) |> Fief.Wire.decode()
{:ok, {:msg, 7, 3, :ping, nil}}
iex> Fief.Wire.decode({:fief, 99, :msg, 7, 3, :ping, nil})
{:error, {:unsupported_protocol, 99}}
iex> Fief.Wire.decode(:other)
{:error, :not_fief}
Build a :moved envelope carrying a routing delta.
iex> Fief.Wire.moved(8, [{3, :"b@host"}])
{:fief, 1, :moved, 8, [{3, :"b@host"}]}
Build a :msg envelope.
iex> Fief.Wire.msg(7, 3, {:key, :get}, nil)
{:fief, 1, :msg, 7, 3, {:key, :get}, nil}
Build a :peer envelope; delivered only on session match (framework-enforced).
iex> session = {3, :"a@host", :"b@host", 8}
iex> Fief.Wire.peer(session, {:pull, "k"})
{:fief, 1, :peer, {3, :"a@host", :"b@host", 8}, {:pull, "k"}}
@spec protocol_version() :: pos_integer()
The wire protocol version this build speaks.