Skip to content
Strata is pre-1.0. APIs, protocol, and storage format may change.

strata_protocol

strata_protocol defines the v0 frame set, presence values, and the JSON encoding and decoding used on both ends of the socket. Because the server and strata_client both depend on it, the two cannot drift apart.

Targets: Erlang and JavaScript.

  • strata_protocol — the envelope: v and kind field names, version constant, shared helpers.
  • strata_protocol/client — client → server frames: join, leave, delta, create, delete, presence_set, ping, with encoders and a decoder.
  • strata_protocol/server — server → client frames: welcome, snapshot, delta, deleted, presence_state, presence_diff, error, pong.
  • strata_protocol/presence — the presence entry type (session_id, name, color, cursor) and its codec.
  • strata_protocol/error — decode errors such as UnknownKind.

The state field of snapshot and delta is carried as opaque JSON; the server interprets it with lattice_crdt.

protocol_version is 0. version_field is "v" and kind_field is "kind".

DecodeError has four variants:

  • InvalidJson(reason);
  • InvalidFormat(reason);
  • UnsupportedVersion(found, expected);
  • UnknownKind(kind).

Use error.format to make one log line from a decode error.

Frame fields, sequence rules, server error codes, and examples are on the Protocol page.

Source: packages/strata_protocol.