Interface SnapshotTrigger
- All Known Implementing Classes:
NoSnapshotTrigger, PeriodicSnapshotTrigger
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface used to determine whether a new snapshot should be created for an aggregate.
Implementations of this interface are consulted during the commit of new events to decide whether a snapshot of
the aggregate's current state should be persisted to the SnapshotStore.
This decision can be based on factors such as the number or type of events since the last snapshot, aggregate version, or specific domain rules.
Snapshotting can improve performance for aggregates with long event histories by reducing the number of events that need to be replayed during reconstruction.
Typical usage involves providing a custom implementation of this interface to an
AggregateRepository or another aggregate loader mechanism.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanshouldCreateSnapshot(Entity<?> model, List<AppliedEvent> newEvents) Determines whether a snapshot should be created for the given aggregate state and recent events.
-
Method Details
-
shouldCreateSnapshot
Determines whether a snapshot should be created for the given aggregate state and recent events.- Parameters:
model- The currentEntityrepresenting the aggregate's state.newEvents- A list ofAppliedEvents that have just been applied to the aggregate and are about to be committed.- Returns:
trueif a snapshot should be created,falseotherwise.
-