Syntropy.EventRecorder
(syntropy v0.2.0)
Copy Markdown
Retains lattice runtime events and broadcasts them on Phoenix PubSub.
Recording is asynchronous: record/2 builds the event in the caller,
casts it to the recorder, and returns immediately. The recorder
broadcasts the event on "lattice:events" as soon as it is received
and persists events in batches (Repo.insert_all) on a short flush
interval, so producers such as the task scheduler never block on
Postgres writes.
The recorder also subscribes to "lattice:events" itself: events that
originate on other cluster nodes (PG PubSub fans them out cluster-wide)
are merged into the in-memory history with uid-based deduplication, so
recent/1 — and therefore GET /api/events and the cockpit event
panel — reflect cluster-wide history. Only locally-recorded events are
persisted; each event reaches the shared database exactly once, from
its origin node.
Summary
Functions
Returns a specification to start this module under a supervisor.
Synchronously persists any batched events that have not been flushed yet.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec flush() :: :ok
Synchronously persists any batched events that have not been flushed yet.
Intended for tests and shutdown paths that need write durability before inspecting the database.
@spec recent(non_neg_integer()) :: [event()]
@spec reset() :: :ok
@spec start_link(keyword()) :: GenServer.on_start()