VersionOffsetSnapshotStrategy

class VersionOffsetSnapshotStrategy(versionOffset: Int = DEFAULT_VERSION_OFFSET, snapshotStore: SnapshotStore) : SnapshotStrategy

Snapshot strategy that creates snapshots based on version offset. A snapshot is created when the current aggregate version exceeds the last snapshot version by the specified offset. This helps balance between snapshot frequency and storage efficiency.

Parameters

versionOffset

The minimum version difference required to trigger a snapshot (default: DEFAULT_VERSION_OFFSET).

snapshotStore

The store to save snapshots to.

Constructors

Link copied to clipboard
constructor(versionOffset: Int = DEFAULT_VERSION_OFFSET, snapshotStore: SnapshotStore)

Types

Link copied to clipboard
object Companion

Functions

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

Processes a state event and creates a snapshot if the version offset threshold is met. Compares the current event version with the last snapshot version to determine if a snapshot should be created.