SnapshotStrategy

Strategy for managing snapshots of state aggregates. Snapshot strategies determine when and how to create snapshots based on state events. This helps optimize aggregate loading by reducing the number of events that need to be replayed.

Implementations can define custom logic for snapshot creation, such as:

  • Taking snapshots after a certain number of events

  • Taking snapshots at specific time intervals

  • Taking snapshots based on aggregate state changes

Author

ahoo wang

Inheritors

Types

Link copied to clipboard

No-operation implementation of SnapshotStrategy that never creates snapshots. Useful for testing or when snapshots are not needed.

Functions

Link copied to clipboard

Wraps a SnapshotStrategy with metrics collection capabilities. Returns a MetricSnapshotStrategy that collects metrics on snapshot strategy operations.

Link copied to clipboard
abstract fun onEvent(stateEventExchange: StateEventExchange<*>): Mono<Void>

Processes a state event exchange to determine if a snapshot should be created. Implementations should analyze the event and potentially trigger snapshot creation.