pub struct Store<Id, M> { /* private fields */ }Expand description
In-memory event store that keeps streams in a hash map.
Uses a global sequence counter (Position = u64) to maintain chronological
ordering across streams, enabling cross-aggregate projections that need to
interleave events by time rather than by stream name.
Generic over:
Id: Aggregate identifier type (must be hashable/equatable for map keys)M: Metadata type (use()when not needed)
This store uses serde_json::Value as the internal data representation.
Implementations§
Trait Implementations§
Source§impl<Id, M> EventStore for Store<Id, M>
impl<Id, M> EventStore for Store<Id, M>
Source§type Error = InMemoryError
type Error = InMemoryError
Store-specific error type.
Source§fn decode_event<E>(
&self,
stored: &StoredEvent<Self::Id, Self::Position, Self::Data, Self::Metadata>,
) -> Result<E, Self::Error>where
E: DomainEvent + DeserializeOwned,
fn decode_event<E>(
&self,
stored: &StoredEvent<Self::Id, Self::Position, Self::Data, Self::Metadata>,
) -> Result<E, Self::Error>where
E: DomainEvent + DeserializeOwned,
Decode a stored event into a concrete event type. Read more
Source§fn stream_version<'a>(
&'a self,
aggregate_kind: &'a str,
aggregate_id: &'a Self::Id,
) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send + 'a
fn stream_version<'a>( &'a self, aggregate_kind: &'a str, aggregate_id: &'a Self::Id, ) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send + 'a
Get the current version (latest position) for an aggregate stream. Read more
Source§fn commit_events<'a, E>(
&'a self,
aggregate_kind: &'a str,
aggregate_id: &'a Self::Id,
events: NonEmpty<E>,
metadata: &'a Self::Metadata,
) -> impl Future<Output = Result<Committed<u64>, CommitError<Self::Error>>> + Send + 'a
fn commit_events<'a, E>( &'a self, aggregate_kind: &'a str, aggregate_id: &'a Self::Id, events: NonEmpty<E>, metadata: &'a Self::Metadata, ) -> impl Future<Output = Result<Committed<u64>, CommitError<Self::Error>>> + Send + 'a
Commit events to an aggregate stream without version checking. Read more
Source§fn commit_events_optimistic<'a, E>(
&'a self,
aggregate_kind: &'a str,
aggregate_id: &'a Self::Id,
expected_version: Option<Self::Position>,
events: NonEmpty<E>,
metadata: &'a Self::Metadata,
) -> impl Future<Output = Result<Committed<u64>, OptimisticCommitError<u64, Self::Error>>> + Send + 'a
fn commit_events_optimistic<'a, E>( &'a self, aggregate_kind: &'a str, aggregate_id: &'a Self::Id, expected_version: Option<Self::Position>, events: NonEmpty<E>, metadata: &'a Self::Metadata, ) -> impl Future<Output = Result<Committed<u64>, OptimisticCommitError<u64, Self::Error>>> + Send + 'a
Commit events to an aggregate stream with optimistic concurrency
control. Read more
Source§fn load_events<'a>(
&'a self,
filters: &'a [EventFilter<Self::Id, Self::Position>],
) -> impl Future<Output = LoadEventsResult<Self::Id, Self::Position, Self::Data, Self::Metadata, Self::Error>> + Send + 'a
fn load_events<'a>( &'a self, filters: &'a [EventFilter<Self::Id, Self::Position>], ) -> impl Future<Output = LoadEventsResult<Self::Id, Self::Position, Self::Data, Self::Metadata, Self::Error>> + Send + 'a
Load events matching the specified filters. Read more
Source§impl<Id, M> SubscribableStore for Store<Id, M>
impl<Id, M> SubscribableStore for Store<Id, M>
Source§fn subscribe(
&self,
filters: &[EventFilter<Self::Id, Self::Position>],
from_position: Option<Self::Position>,
) -> Pin<Box<dyn Stream<Item = Result<StoredEvent<Self::Id, Self::Position, Self::Data, Self::Metadata>, Self::Error>> + Send + '_>>
fn subscribe( &self, filters: &[EventFilter<Self::Id, Self::Position>], from_position: Option<Self::Position>, ) -> Pin<Box<dyn Stream<Item = Result<StoredEvent<Self::Id, Self::Position, Self::Data, Self::Metadata>, Self::Error>> + Send + '_>>
Subscribe to events matching the given filters. Read more
impl<Id, M> GloballyOrderedStore for Store<Id, M>
Auto Trait Implementations§
impl<Id, M> Freeze for Store<Id, M>
impl<Id, M> RefUnwindSafe for Store<Id, M>
impl<Id, M> Send for Store<Id, M>
impl<Id, M> Sync for Store<Id, M>
impl<Id, M> Unpin for Store<Id, M>
impl<Id, M> UnwindSafe for Store<Id, M>
Blanket Implementations§
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