Module event_log

Module event_log 

Source

StructsΒ§

EventLog
Append-only ring + optional disk persistence.

ConstantsΒ§

MAX_DISK_BYTES πŸ”’
Cap on disk file size before rotation. 8 MiB β‰ˆ 4–8K events depending on event variant. Two-file rotation: when current exceeds this, rename to .old (overwriting any prior .old) and start fresh. Total worst-case footprint: 2 Γ— MAX_DISK_BYTES.
MAX_RING_EVENTS πŸ”’
Cap on in-memory ring size. 4096 events is comfortable for realistic resync windows (~minutes of activity at typical reducer event rates: 10–50 events per user action). Tunable upward if forensics in long sessions show truncation; downward would only be useful if we measured noticeable memory pressure from this (we don’t β€” Event is small and there are 4096 of them).

FunctionsΒ§

event_version πŸ”’
Extract the version field from any Event variant. Mirrors reducer.rs::extract_version (which is test-only; the prod code path needs its own copy here). When a new variant is added that carries a version, add it here too β€” the unreachable arm catches future-variant compile errors.
open_for_append πŸ”’
run_disk_writer
Background task: write events to the disk file as they arrive on the broadcast bus. Rotates when the file exceeds MAX_DISK_BYTES.