Skip to main content

MutationRecorder

Trait MutationRecorder 

Source
pub trait MutationRecorder:
    Send
    + Sync
    + 'static {
    // Required method
    fn record(&self, event: &MutationEvent);

    // Provided method
    fn poisoned(&self) -> Option<String> { ... }
}
Expand description

Observer that receives every successful mutation in the order the store applied it.

The recorder sees events after the mutation has been applied to the in-memory state, so it never observes a mutation that the store rejected (invalid id, empty relationship type, …). This matches the classic write-ahead-log convention of logging committed changes only.

Implementations must be Send + Sync so a shared recorder can be driven from any thread holding the store’s write lock.

Required Methods§

Source

fn record(&self, event: &MutationEvent)

Provided Methods§

Source

fn poisoned(&self) -> Option<String>

Sticky failure flag for durability-shaped recorders.

record itself is infallible — non-WAL observers (audit taps, replication shadows, CDC sinks) should not abort a write because their downstream queue is full. Recorders that do care about durability — most importantly the WAL adapter — flip a flag when an append fails and surface it here. The host (typically Database::execute_with_params) polls this once per critical section while still holding the store write lock; if poisoned, the query fails loudly and the caller observes the durability error rather than a silently-lost write.

The default returns None, so existing recorders compile unchanged.

Implementors§

Source§

impl<F> MutationRecorder for ClosureRecorder<F>
where F: Fn(&MutationEvent) + Send + Sync + 'static,