Skip to main content

Module memory_ingest

Module memory_ingest 

Available on crate feature memory only.
Expand description

An in-memory store that both appends and ingests, behind the memory feature: the oracle the ingest family is proven against.

§Why it exists: three jobs, one type

The three jobs MemorySyncPeer does, one port over:

  1. The oracle. happenstance-sync-testkit’s ingest family is pointed at this store first. A rule red here is a wrong rule, not a wrong store.
  2. The doctest target. An example that needs a store which ingests uses this one, so it runs rather than merely compiles.
  3. Something to test against. A runner can be written and tested before any adapter implements IngestStore.

§Why it is not MemoryEventStore

MemoryEventStore lives in happenstance-core, and its only &self writer is append, which mints. Coherence lets this crate add a trait to it and never lets it reach inside (see ingest), so the oracle owns its log. It is built from happenstance-core’s public API alone, and what it can take from the reference store it takes rather than copies:

  • Its incarnation. MemoryIngestStore::new uses the identifier a fresh MemoryEventStore would mint, so two oracles never share a StoreId.
  • Its clock. A local append and a compensation are stamped by MemoryEventStore::with_events, so the seam that keeps that store total on wasm32-unknown-unknown, which has no clock, is not copied here.
  • Its error. MemoryStoreError, which is uninhabited, serves both ports, so “the in-memory store cannot fail” has one name.

What it cannot take is read’s filter chain, which is duplicated. The event-store suite and a differential test against MemoryEventStore hold the copy to the original.

It is not built for scale. Every read snapshots under the lock, and every membership question is a set lookup over everything held.

Structs§

MemoryIngestStore
An in-memory EventStore that is also an IngestStore.