pub struct CompactionAuditSink { /* private fields */ }Expand description
Async bounded-mpsc audit sink for compaction records.
The sink serialises CompactedPageRecord values to a JSONL file via a
background writer task, mirroring the zeph-tools audit pattern. Dropped
records (when the channel is full) are counted and logged.
§Invariant
CompactionAuditSink::flush sends a rendezvous sentinel through the channel
and awaits the writer task’s confirmation with a 100 ms timeout. Records accepted
into the channel before flush is called are guaranteed to be written before the
flush responder fires.
§Examples
use zeph_context::typed_page::CompactionAuditSink;
use std::path::Path;
let sink = CompactionAuditSink::open(Path::new(".local/audit/compaction.jsonl"), 256)
.await
.unwrap();Implementations§
Source§impl CompactionAuditSink
impl CompactionAuditSink
Sourcepub async fn open(path: &Path, capacity: usize) -> Result<Self, Error>
pub async fn open(path: &Path, capacity: usize) -> Result<Self, Error>
Open a new audit sink writing to path.
capacity is the bounded channel depth; records dropped when full are counted
in the internal drop counter and logged at WARN.
§Errors
Returns an error when path cannot be opened for appending.
Sourcepub fn send(&self, record: CompactedPageRecord)
pub fn send(&self, record: CompactedPageRecord)
Send a record to the audit sink.
If the channel is full the record is dropped and the drop counter is incremented.
Sourcepub async fn flush(&self)
pub async fn flush(&self)
Flush all pending records with bounded 100 ms timeout.
Sends a Flush sentinel through the same channel as records, so ordering is
preserved — the writer task responds only after all preceding records are written.
If the writer task does not respond within 100 ms, the flush times out silently.
Sourcepub fn dropped_count(&self) -> u64
pub fn dropped_count(&self) -> u64
Number of records dropped due to a full channel.
Trait Implementations§
Source§impl Clone for CompactionAuditSink
impl Clone for CompactionAuditSink
Source§fn clone(&self) -> CompactionAuditSink
fn clone(&self) -> CompactionAuditSink
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more