Module event_log_writer

Module event_log_writer 

Source
Expand description

Event-log writer task: dedicated consumer of EventLogEntry values the reducer-task applier emits, persisting them to SQLite outside the reducer’s critical section.

The applier hands entries to this task via EventLogTx. The reducer never touches Db::event_log() directly — that keeps the reducer task free of the SQLite Mutex during high-frequency RemoteAppendEventLog / RecordTransition effects, and isolates writer hiccups (disk fsync pauses, mutex contention) from the per-host step() path.

Backpressure: the channel is bounded. When full, the applier’s send().await waits — which surfaces the slowdown back into the reducer’s input MPSC, preserving the no-fail-open contract for the audit log (RFC-0005 §6: every gate decision and state transition must reach the log; silently dropping is forbidden).

Constants§

EVENT_LOG_CHANNEL_CAPACITY
Bounded channel depth for event-log entries between the reducer applier and the writer task.

Functions§

drain_pending 🔒
Best-effort drain of in-flight entries on shutdown. Skips send().await because we’re past the cancellation point — no new entries can arrive (every applier holds a Sender that’s already been dropped or is about to be).
spawn
Spawn the writer task. Returns the JoinHandle for the runtime drain.

Type Aliases§

EventLogRx
EventLogTx