Skip to main content

EventStore

Trait EventStore 

Source
pub trait EventStore: Send + Sync {
    // Required methods
    fn append(
        &self,
        run_id: &RunId,
        events: &[Event],
    ) -> Result<Seq, KernelError>;
    fn scan(
        &self,
        run_id: &RunId,
        from: Seq,
    ) -> Result<Vec<SequencedEvent>, KernelError>;
    fn head(&self, run_id: &RunId) -> Result<Seq, KernelError>;
}
Expand description

Event store: append-only log per run, source of truth.

Constraints (must hold in all implementations and tests):

  • append: either all events in the batch succeed or none (atomicity).
  • Each event has a seq (assigned by store or caller).
  • scan(run_id, from) returns events in ascending seq order.

Required Methods§

Source

fn append(&self, run_id: &RunId, events: &[Event]) -> Result<Seq, KernelError>

Appends events for the given run. Returns the seq of the last written event (or an error). Implementations must assign seqs if not present and guarantee atomicity.

Source

fn scan( &self, run_id: &RunId, from: Seq, ) -> Result<Vec<SequencedEvent>, KernelError>

Scans events for the run starting at from (inclusive), in ascending seq order.

Source

fn head(&self, run_id: &RunId) -> Result<Seq, KernelError>

Returns the highest seq for the run (0 if no events).

Implementors§