Bellwether.Frame (bellwether v0.1.0)

Copy Markdown

Encoding an Event for the Agent socket.

Four bytes of big-endian length, then CBOR. The field names are single letters and the enums are integers because this is the same representation that later crosses a metered link — encoding it once, on the device, keeps the Agent from having to re-shape anything.

The mapping is fixed by the Agent, which decodes it. Both sides are tested against a shared fixture, so an encoder and a decoder cannot drift apart without something failing.

Summary

Functions

Decode a frame. Used by the tests to read what the Agent's encoder produced; the Adapter itself only ever writes.

Frame an Event.

Functions

decode(arg1)

@spec decode(binary()) :: {:ok, map(), binary()} | :incomplete | {:error, term()}

Decode a frame. Used by the tests to read what the Agent's encoder produced; the Adapter itself only ever writes.

encode(event)

@spec encode(map()) :: {:ok, binary()} | {:error, :oversize}

Frame an Event.

Required: :domain and :kind — what the Adapter knows. Optional: :at, :fingerprint, :count, :payload, :crumbs, :truncated.

Identity — :id, :boot, :mono — is not required and is normally absent. The Agent stamps it on receipt: an Adapter has no way to know the boot id, and its monotonic clock has a different base from the Agent's. Anything an Adapter does supply is passed through and the Agent respects it.