pub struct EventLog {
ring: Mutex<VecDeque<Event>>,
disk_path: Option<PathBuf>,
}Expand description
Append-only ring + optional disk persistence.
Cloneable via Arc<EventLog> from the IPC server context;
append and events_since are cheap (Mutex held for
microseconds — Vec
Disk writes happen on a dedicated tokio task that subscribes to the broadcast bus separately from the in-memory append. This means the in-memory ring is updated synchronously from the IPC server’s dispatch path; disk persistence runs at its own pace and may lag.
Fields§
§ring: Mutex<VecDeque<Event>>§disk_path: Option<PathBuf>Implementations§
Source§impl EventLog
impl EventLog
Sourcepub fn new(disk_path: Option<PathBuf>) -> Self
pub fn new(disk_path: Option<PathBuf>) -> Self
Construct an event log. disk_path = None disables disk
persistence (used in tests where filesystem state is
inconvenient). The on-disk file is created on first append;
no upfront I/O.
Sourcepub fn append(&self, event: Event)
pub fn append(&self, event: Event)
Append an event to the in-memory ring. Evicts the oldest entry when the ring is at capacity. Synchronous, O(1)-amortized.
Sourcepub fn events_since(&self, since: u64) -> Vec<Event>
pub fn events_since(&self, since: u64) -> Vec<Event>
Snapshot of all events currently in the ring with version >
since. Returned in insertion order (oldest first), so the
caller applies them sequentially.
Phase D.3 — used by Command::GetEvents { since } to
produce the replay slice. The snapshot is taken at-call-time;
events arriving after this returns are NOT included (the
subscriber sees them on the live broadcast stream).
Sourcepub fn replay_truncated(&self, since: u64) -> bool
pub fn replay_truncated(&self, since: u64) -> bool
True if the requested since version is older than the
oldest event in the ring (i.e. the subscriber missed events
that have already been evicted). Caller should treat the
resulting events_since slice as best-effort and may need
to re-fetch a snapshot to recover canonical state.