pub struct EventStore { /* private fields */ }Expand description
Main event store implementation
Implementations§
Source§impl EventStore
impl EventStore
Sourcepub fn new(config: EventStoreConfig) -> Self
pub fn new(config: EventStoreConfig) -> Self
Create a new event store
Sourcepub async fn store_event(
&self,
stream_id: String,
event: StreamEvent,
) -> Result<StoredEvent>
pub async fn store_event( &self, stream_id: String, event: StreamEvent, ) -> Result<StoredEvent>
Store an event in the event store
Sourcepub async fn query_events(&self, query: EventQuery) -> Result<Vec<StoredEvent>>
pub async fn query_events(&self, query: EventQuery) -> Result<Vec<StoredEvent>>
Retrieve events by query
Sourcepub async fn get_stream_events(
&self,
stream_id: &str,
from_version: Option<u64>,
) -> Result<Vec<StoredEvent>>
pub async fn get_stream_events( &self, stream_id: &str, from_version: Option<u64>, ) -> Result<Vec<StoredEvent>>
Get events for a specific stream
Sourcepub async fn replay_from_timestamp(
&self,
timestamp: DateTime<Utc>,
) -> Result<Vec<StoredEvent>>
pub async fn replay_from_timestamp( &self, timestamp: DateTime<Utc>, ) -> Result<Vec<StoredEvent>>
Replay events from a specific point in time
Sourcepub async fn get_latest_snapshot(
&self,
stream_id: &str,
) -> Result<Option<EventSnapshot>>
pub async fn get_latest_snapshot( &self, stream_id: &str, ) -> Result<Option<EventSnapshot>>
Get the latest snapshot for a stream
Sourcepub async fn rebuild_stream_state(&self, stream_id: &str) -> Result<Vec<u8>>
pub async fn rebuild_stream_state(&self, stream_id: &str) -> Result<Vec<u8>>
Rebuild stream state from events and snapshots
Sourcepub fn get_stats(&self) -> EventSourcingStats
pub fn get_stats(&self) -> EventSourcingStats
Get event sourcing statistics
Trait Implementations§
Source§impl EventStoreTrait for EventStore
Implement the EventStoreTrait for the concrete EventStore
impl EventStoreTrait for EventStore
Implement the EventStoreTrait for the concrete EventStore
fn store_event<'life0, 'async_trait>(
&'life0 self,
stream_id: String,
event: StreamEvent,
) -> Pin<Box<dyn Future<Output = Result<StoredEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query_events<'life0, 'async_trait>(
&'life0 self,
query: EventQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_stream_events<'life0, 'life1, 'async_trait>(
&'life0 self,
stream_id: &'life1 str,
from_version: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn replay_from_timestamp<'life0, 'async_trait>(
&'life0 self,
timestamp: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<Vec<StoredEvent>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_latest_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
stream_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<EventSnapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn rebuild_stream_state<'life0, 'life1, 'async_trait>(
&'life0 self,
stream_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn append_events<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
events: &'life2 [StreamEvent],
_expected_version: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Auto Trait Implementations§
impl Freeze for EventStore
impl !RefUnwindSafe for EventStore
impl Send for EventStore
impl Sync for EventStore
impl Unpin for EventStore
impl UnsafeUnpin for EventStore
impl !UnwindSafe for EventStore
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.