pub struct Store<M> { /* private fields */ }Expand description
A PostgreSQL-backed EventStore.
Defaults are intentionally conservative:
- Positions are global and monotonic (
i64, backed byBIGSERIAL). - Metadata is stored as
jsonb(M: Serialize + DeserializeOwned). - Event data is stored as
jsonb.
Implementations§
Trait Implementations§
Source§impl<M> EventStore for Store<M>
impl<M> EventStore for Store<M>
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§async fn stream_version<'a>(
&'a self,
aggregate_kind: &'a str,
aggregate_id: &'a Self::Id,
) -> Result<Option<Self::Position>, Self::Error>
async fn stream_version<'a>( &'a self, aggregate_kind: &'a str, aggregate_id: &'a Self::Id, ) -> Result<Option<Self::Position>, Self::Error>
Get the current version (latest position) for an aggregate stream. Read more
Source§async fn commit_events<'a, E>(
&'a self,
aggregate_kind: &'a str,
aggregate_id: &'a Self::Id,
events: NonEmpty<E>,
metadata: &'a Self::Metadata,
) -> Result<Committed<i64>, CommitError<Self::Error>>
async fn commit_events<'a, E>( &'a self, aggregate_kind: &'a str, aggregate_id: &'a Self::Id, events: NonEmpty<E>, metadata: &'a Self::Metadata, ) -> Result<Committed<i64>, CommitError<Self::Error>>
Commit events to an aggregate stream without version checking. Read more
Source§async 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,
) -> Result<Committed<i64>, OptimisticCommitError<i64, Self::Error>>
async 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, ) -> Result<Committed<i64>, OptimisticCommitError<i64, Self::Error>>
Commit events to an aggregate stream with optimistic concurrency
control. Read more
Source§async fn load_events<'a>(
&'a self,
filters: &'a [EventFilter<Self::Id, Self::Position>],
) -> LoadEventsResult<Self::Id, Self::Position, Self::Data, Self::Metadata, Self::Error>
async fn load_events<'a>( &'a self, filters: &'a [EventFilter<Self::Id, Self::Position>], ) -> LoadEventsResult<Self::Id, Self::Position, Self::Data, Self::Metadata, Self::Error>
Load events matching the specified filters. Read more
impl<M> GloballyOrderedStore for Store<M>
Auto Trait Implementations§
impl<M> Freeze for Store<M>
impl<M> !RefUnwindSafe for Store<M>
impl<M> Send for Store<M>where
M: Send,
impl<M> Sync for Store<M>where
M: Sync,
impl<M> Unpin for Store<M>where
M: Unpin,
impl<M> !UnwindSafe for Store<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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