pub struct SnapshotService<S: SnapshotStore> { /* private fields */ }Expand description
Service for managing aggregate snapshots
Implementations§
Source§impl<S: SnapshotStore> SnapshotService<S>
impl<S: SnapshotStore> SnapshotService<S>
pub fn new(store: S, config: SnapshotConfig) -> Self
Sourcepub async fn create_snapshot(
&self,
aggregate_id: AggregateId,
aggregate_type: String,
aggregate_version: AggregateVersion,
state_data: Vec<u8>,
event_count: usize,
) -> Result<AggregateSnapshot>
pub async fn create_snapshot( &self, aggregate_id: AggregateId, aggregate_type: String, aggregate_version: AggregateVersion, state_data: Vec<u8>, event_count: usize, ) -> Result<AggregateSnapshot>
Create a snapshot from aggregate state data
Sourcepub async fn load_latest_snapshot(
&self,
aggregate_id: &AggregateId,
) -> Result<Option<AggregateSnapshot>>
pub async fn load_latest_snapshot( &self, aggregate_id: &AggregateId, ) -> Result<Option<AggregateSnapshot>>
Load the most recent snapshot for an aggregate
Sourcepub fn decompress_snapshot_data(
&self,
snapshot: &AggregateSnapshot,
) -> Result<Vec<u8>>
pub fn decompress_snapshot_data( &self, snapshot: &AggregateSnapshot, ) -> Result<Vec<u8>>
Decompress snapshot data
Sourcepub async fn should_take_snapshot(
&self,
aggregate_id: &AggregateId,
current_version: AggregateVersion,
) -> Result<bool>
pub async fn should_take_snapshot( &self, aggregate_id: &AggregateId, current_version: AggregateVersion, ) -> Result<bool>
Check if a snapshot should be taken
Sourcepub async fn cleanup_old_snapshots(&self) -> Result<u64>
pub async fn cleanup_old_snapshots(&self) -> Result<u64>
Perform cleanup of old snapshots
Auto Trait Implementations§
impl<S> Freeze for SnapshotService<S>where
S: Freeze,
impl<S> RefUnwindSafe for SnapshotService<S>where
S: RefUnwindSafe,
impl<S> Send for SnapshotService<S>where
S: Send,
impl<S> Sync for SnapshotService<S>where
S: Sync,
impl<S> Unpin for SnapshotService<S>where
S: Unpin,
impl<S> UnwindSafe for SnapshotService<S>where
S: UnwindSafe,
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 more