VersionOffsetSnapshotStrategy

class VersionOffsetSnapshotStrategy(versionOffset: Int = DEFAULT_VERSION_OFFSET, snapshotRepository: SnapshotRepository) : 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).

snapshotRepository

The repository to save snapshots to.

Constructors

Link copied to clipboard
constructor(versionOffset: Int = DEFAULT_VERSION_OFFSET, snapshotRepository: SnapshotRepository)

Types

Link copied to clipboard
object Companion

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
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.