pub struct MemoryBackend { /* private fields */ }Expand description
In-memory implementation of EventStore.
Stores entries densely in a Vec keyed by seq - 1 plus one [IndexMap] per
IndexKind for the sidecar indices. Hash recomputation on read is structurally
redundant (entries live in process memory) but kept for parity with persistent
backends so callers see uniform behavior.
One backend instance owns at most one open run at a time. Sealing the open run leaves
the manifest and entries readable until the next EventStore::open_run call replaces
them with a fresh run. Reopening while a Running run still exists returns
EventStoreError::CrashedPredecessor so callers exercise the same crash-recovery
path persistent backends surface on reopen.
Implementations§
Source§impl MemoryBackend
impl MemoryBackend
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty MemoryBackend with no run open.
Trait Implementations§
Source§impl Debug for MemoryBackend
impl Debug for MemoryBackend
Source§impl Default for MemoryBackend
impl Default for MemoryBackend
Source§fn default() -> MemoryBackend
fn default() -> MemoryBackend
Returns the “default value” for a type. Read more
Source§impl EventStore for MemoryBackend
impl EventStore for MemoryBackend
Source§fn open_run(&mut self, manifest: RunManifest) -> Result<(), EventStoreError>
fn open_run(&mut self, manifest: RunManifest) -> Result<(), EventStoreError>
Opens an existing run or creates a new one with the supplied manifest. Read more
Source§fn append_batch(
&mut self,
entries: &[AppendEntry],
) -> Result<u64, EventStoreError>
fn append_batch( &mut self, entries: &[AppendEntry], ) -> Result<u64, EventStoreError>
Appends a batch of
(entry, index_keys) pairs in a single backend transaction. Read moreSource§fn scan_range(
&self,
from: u64,
to: u64,
direction: ScanDirection,
) -> Result<Vec<EventStoreEntry>, EventStoreError>
fn scan_range( &self, from: u64, to: u64, direction: ScanDirection, ) -> Result<Vec<EventStoreEntry>, EventStoreError>
Source§fn scan_seq(&self, seq: u64) -> Result<Option<EventStoreEntry>, EventStoreError>
fn scan_seq(&self, seq: u64) -> Result<Option<EventStoreEntry>, EventStoreError>
Reads a single entry by
seq. Read moreSource§fn lookup(
&self,
kind: IndexKind,
key: &str,
) -> Result<Option<u64>, EventStoreError>
fn lookup( &self, kind: IndexKind, key: &str, ) -> Result<Option<u64>, EventStoreError>
Looks up the first
seq recorded under the given index key. Read moreSource§fn iter_index_keys(
&self,
kind: IndexKind,
) -> Result<Vec<(String, u64)>, EventStoreError>
fn iter_index_keys( &self, kind: IndexKind, ) -> Result<Vec<(String, u64)>, EventStoreError>
Enumerates every
(key, seq) pair stored under the given secondary index. Read moreSource§fn record_snapshot_anchor(
&mut self,
anchor: SnapshotAnchor,
) -> Result<(), EventStoreError>
fn record_snapshot_anchor( &mut self, anchor: SnapshotAnchor, ) -> Result<(), EventStoreError>
Records the latest cache snapshot anchor for the open run. Read more
Source§fn latest_snapshot_anchor(
&self,
) -> Result<Option<SnapshotAnchor>, EventStoreError>
fn latest_snapshot_anchor( &self, ) -> Result<Option<SnapshotAnchor>, EventStoreError>
Returns the latest recorded snapshot anchor for the open run. Read more
Source§fn seal(&mut self, status: RunStatus) -> Result<(), EventStoreError>
fn seal(&mut self, status: RunStatus) -> Result<(), EventStoreError>
Seals the open run with the given final status and persists the manifest update. Read more
Source§fn manifest(&self) -> Result<RunManifest, EventStoreError>
fn manifest(&self) -> Result<RunManifest, EventStoreError>
Returns the current manifest snapshot. Read more
Source§fn high_watermark(&self) -> Result<u64, EventStoreError>
fn high_watermark(&self) -> Result<u64, EventStoreError>
Returns the largest
seq durably acknowledged for the open run. Read moreAuto Trait Implementations§
impl Freeze for MemoryBackend
impl RefUnwindSafe for MemoryBackend
impl Send for MemoryBackend
impl Sync for MemoryBackend
impl Unpin for MemoryBackend
impl UnsafeUnpin for MemoryBackend
impl UnwindSafe for MemoryBackend
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more