Skip to main content

Module event

Module event 

Source
Expand description

The event log’s envelope: an open kind name and an opaque payload.

An EventRecord is what the store holds and the server serves, and the one thing every domain and every client agree on about it is its shape: the fields every event carries, a kind naming which event it is, and a payload whose form is the kind’s own. Nothing here lists the kinds. Each is declared by the domain that owns the event — a payload type implementing EventPayload under a KIND of its own — so a domain that adds an event edits its own crate and nothing central.

§Why the log is open

A closed pair — one enum of kinds and one enum of payloads, a variant per domain’s events — made the crate every other crate builds against the place every domain’s payload had to be written, and let a reader match on another domain’s kind by name. The envelope makes neither possible: a reader of the log carries a record through, filters by name, or reads a typed payload out of it with EventBody::read and is answered nothing when the kind is another’s. A record under a kind no crate of this workspace declares — a row written by a newer server, say — survives a round trip unchanged.

§The wire form, which is unchanged

EventBody is flattened into the record, so the wire form of a record is still the fields id, print_id, source, received_at, image, kind, payload and raw, and {"kind": .., "payload": ..} is the text the closed pair’s tagged form serialized to.

Structs§

EventBody
The kind and the payload, as the log holds them.
EventKind
The name one kind of event is written down under.
EventKindError
Why a string is not a kind name.
EventRecord
One event, as the store holds it and the server serves it.
EventSource
Where an event came from, as the bare string each domain declares for itself.

Constants§

KIND_PATTERN
The pattern every kind name matches: lowercase snake_case.

Traits§

EventPayload
One typed payload declared under a kind name, by the domain that owns it.