pub struct InMemorySnapshotStore<Id, Pos> { /* private fields */ }Expand description
In-memory snapshot store with configurable policy.
This is a reference implementation suitable for testing and development.
Production systems should implement SnapshotStore with durable storage.
Generic over Id and Pos to match the EventStore types.
§Example
ⓘ
use sourcery::{Repository, InMemoryEventStore, InMemorySnapshotStore, JsonCodec};
let repo = Repository::new(InMemoryEventStore::new(JsonCodec))
.with_snapshots(InMemorySnapshotStore::every(100));Implementations§
Source§impl<Id, Pos> InMemorySnapshotStore<Id, Pos>
impl<Id, Pos> InMemorySnapshotStore<Id, Pos>
Sourcepub fn always() -> Self
pub fn always() -> Self
Create a snapshot store that saves after every command.
Best for aggregates with expensive replay or many events. See the policy guidelines above for choosing an appropriate cadence.
Trait Implementations§
Source§impl<Id: Clone, Pos: Clone> Clone for InMemorySnapshotStore<Id, Pos>
impl<Id: Clone, Pos: Clone> Clone for InMemorySnapshotStore<Id, Pos>
Source§fn clone(&self) -> InMemorySnapshotStore<Id, Pos>
fn clone(&self) -> InMemorySnapshotStore<Id, Pos>
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Id, Pos> Default for InMemorySnapshotStore<Id, Pos>
impl<Id, Pos> Default for InMemorySnapshotStore<Id, Pos>
Source§impl<Id, Pos> SnapshotStore for InMemorySnapshotStore<Id, Pos>
impl<Id, Pos> SnapshotStore for InMemorySnapshotStore<Id, Pos>
Source§type Error = Infallible
type Error = Infallible
Error type for snapshot operations.
Source§fn load<'a>(
&'a self,
aggregate_kind: &'a str,
aggregate_id: &'a Self::Id,
) -> impl Future<Output = Result<Option<Snapshot<Pos>>, Self::Error>> + Send + 'a
fn load<'a>( &'a self, aggregate_kind: &'a str, aggregate_id: &'a Self::Id, ) -> impl Future<Output = Result<Option<Snapshot<Pos>>, Self::Error>> + Send + 'a
Load the most recent snapshot for an aggregate. Read more
Source§fn offer_snapshot<'a, CE, Create>(
&'a mut self,
aggregate_kind: &'a str,
aggregate_id: &'a Self::Id,
events_since_last_snapshot: u64,
create_snapshot: Create,
) -> impl Future<Output = Result<SnapshotOffer, OfferSnapshotError<Self::Error, CE>>> + Send + 'a
fn offer_snapshot<'a, CE, Create>( &'a mut self, aggregate_kind: &'a str, aggregate_id: &'a Self::Id, events_since_last_snapshot: u64, create_snapshot: Create, ) -> impl Future<Output = Result<SnapshotOffer, OfferSnapshotError<Self::Error, CE>>> + Send + 'a
Whether to store a snapshot, with lazy snapshot creation. Read more
Auto Trait Implementations§
impl<Id, Pos> Freeze for InMemorySnapshotStore<Id, Pos>
impl<Id, Pos> RefUnwindSafe for InMemorySnapshotStore<Id, Pos>where
Id: RefUnwindSafe,
Pos: RefUnwindSafe,
impl<Id, Pos> Send for InMemorySnapshotStore<Id, Pos>
impl<Id, Pos> Sync for InMemorySnapshotStore<Id, Pos>
impl<Id, Pos> Unpin for InMemorySnapshotStore<Id, Pos>
impl<Id, Pos> UnwindSafe for InMemorySnapshotStore<Id, Pos>where
Id: UnwindSafe,
Pos: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)