Interface AggregateSnapshotDeletionStrategy
-
- All Known Implementing Classes:
AggregateSnapshotDeletionStrategy.DeleteAllHistoricSnapshots,AggregateSnapshotDeletionStrategy.KeepHistoricSnapshots
public interface AggregateSnapshotDeletionStrategyStrategy for which historic aggregate snapshots (i.e. old aggregate snapshots) should be deleted when a new aggregate snapshot is persisted
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classAggregateSnapshotDeletionStrategy.DeleteAllHistoricSnapshotsStrategy that deletes any historic aggregate snapshots when a new snapshot is persistedstatic classAggregateSnapshotDeletionStrategy.KeepHistoricSnapshotsStrategy that keeps all or a specific number of historic aggregate snapshots
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static AggregateSnapshotDeletionStrategydeleteAllHistoricSnapshots()Strategy that deletes any historic aggregate snapshots when a new aggregate snapshot is persistedstatic AggregateSnapshotDeletionStrategykeepALimitedNumberOfHistoricSnapshots(long numberOfHistoricSnapshotsToKeep)Strategy that keeps a specific number historic aggregate snapshotsstatic AggregateSnapshotDeletionStrategykeepAllHistoricSnapshots()Strategy that keeps all historic aggregate snapshotsbooleanrequiresExistingSnapshotDetailsToDetermineWhichAggregateSnapshotsToDelete()Guard method that determines if Aggregate Snapshot statistics are required in order to determine which Snapshots to delete<ID,AGGREGATE_IMPL_TYPE>
Stream<AggregateSnapshot<ID,AGGREGATE_IMPL_TYPE>>resolveSnapshotsToDelete(List<AggregateSnapshot<ID,AGGREGATE_IMPL_TYPE>> existingSnapshots)Out of all the existing snapshots (loaded without the snapshot payload), return theAggregateSnapshot's that should be deleted
This method is called just prior to adding a newAggregateSnapshot, so if the purpose it to keep 3 snapshots, and we already have 3 snapshots, then this method should return aStreamcontaining the oldest snapshot, which will then be deleted
-
-
-
Method Detail
-
keepALimitedNumberOfHistoricSnapshots
static AggregateSnapshotDeletionStrategy keepALimitedNumberOfHistoricSnapshots(long numberOfHistoricSnapshotsToKeep)
Strategy that keeps a specific number historic aggregate snapshots- Parameters:
numberOfHistoricSnapshotsToKeep- the number of historic aggregate snapshots to keep- Returns:
- Strategy that keeps all historic aggregate snapshot events
-
keepAllHistoricSnapshots
static AggregateSnapshotDeletionStrategy keepAllHistoricSnapshots()
Strategy that keeps all historic aggregate snapshots- Returns:
- Strategy that keeps all historic aggregate snapshots
-
deleteAllHistoricSnapshots
static AggregateSnapshotDeletionStrategy deleteAllHistoricSnapshots()
Strategy that deletes any historic aggregate snapshots when a new aggregate snapshot is persisted- Returns:
- Strategy that deletes any historic aggregate snapshots when a new aggregate snapshot is persisted
-
requiresExistingSnapshotDetailsToDetermineWhichAggregateSnapshotsToDelete
boolean requiresExistingSnapshotDetailsToDetermineWhichAggregateSnapshotsToDelete()
Guard method that determines if Aggregate Snapshot statistics are required in order to determine which Snapshots to delete- Returns:
- true if
AggregateSnapshotRepository.aggregateUpdated(Object, AggregateEventStream)should fetch existingAggregateSnapshot's (without the payload) as input toresolveSnapshotsToDelete(List)or false if all existing snapshots can be deleted (solvesAggregateSnapshotDeletionStrategy.DeleteAllHistoricSnapshotswithout incurring additional DB queries)
-
resolveSnapshotsToDelete
<ID,AGGREGATE_IMPL_TYPE> Stream<AggregateSnapshot<ID,AGGREGATE_IMPL_TYPE>> resolveSnapshotsToDelete(List<AggregateSnapshot<ID,AGGREGATE_IMPL_TYPE>> existingSnapshots)
Out of all the existing snapshots (loaded without the snapshot payload), return theAggregateSnapshot's that should be deleted
This method is called just prior to adding a newAggregateSnapshot, so if the purpose it to keep 3 snapshots, and we already have 3 snapshots, then this method should return aStreamcontaining the oldest snapshot, which will then be deleted- Type Parameters:
ID- the id type for the aggregateAGGREGATE_IMPL_TYPE- the aggregate type implementation type- Parameters:
existingSnapshots- all the existing snapshots pertaining to a given aggregate instance- Returns:
- all the
AggregateSnapshot's that should be deleted
-
-