anagrapheus.timeline.registry¶
anagrapheus.timeline.registry
¶
The event-type registry: the log's vocabulary, declared in code.
Applications own event names; the library owns only the substrate. Concrete payload types are registered here at the composition root, and duplicate registration fails at import time — schema lives in code, where drift is a crash rather than a runtime surprise.
EventKey
¶
Bases: NamedTuple
The registry key: what identifies an event type on the wire.
EventTypeRegistry
¶
Maps event keys to payload models and back.
The only path between raw payloads and typed events, in both directions: models
are serialized through :meth:pending and decoded through :meth:decode.
Source code in src/anagrapheus/timeline/registry.py
register
¶
Register a payload model under a key. Duplicates raise immediately.
The "anagrapheus" namespace is reserved for this library's own events —
rejecting it here is what makes the reservation collision-proof rather than
advisory.
Source code in src/anagrapheus/timeline/registry.py
event
¶
Class-decorator sugar over :meth:register.
Source code in src/anagrapheus/timeline/registry.py
key_for
¶
Return the key a model was registered under.
pending
¶
pending(
event: DomainEvent,
*,
causation_id: UUID | None = None,
correlation_id: UUID | None = None,
) -> PendingEvent
Wrap a registered payload in an envelope, ready for append.
Source code in src/anagrapheus/timeline/registry.py
decode
¶
Validate a raw payload into the model registered for key.
Source code in src/anagrapheus/timeline/registry.py
latest_version
¶
Return the highest registered schema version for (namespace, type).