Skip to main content

Journal

Trait Journal 

Source
pub trait Journal: Send + Sync {
    // Required method
    fn record(&self, event: Event);

    // Provided method
    fn enabled(&self) -> bool { ... }
}
Expand description

Somewhere decision events go.

&self rather than &mut self on purpose: the writer thread holds this while it owns the log, and a journal that needed exclusive access would either serialize behind the writer or force a lock onto the decision path.

Required Methods§

Source

fn record(&self, event: Event)

Records one event. Must not block and must not panic.

Provided Methods§

Source

fn enabled(&self) -> bool

Whether building an Event for this journal is worth it.

An Event owns its strings, so constructing one costs several allocations before record can discard it. On the writer thread, per op, that is not free: wiring the journal in without this guard pushed the submit path from 174 to 212 allocations per op and submit_path_allocation_budget failed, which is the test working. Call sites check this first, so a node with no journal pays nothing at all rather than paying to be ignored.

Implementors§