From dee0d32d28466bc755d9b1103384b46bb8d85fb9 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sun, 23 Mar 2025 00:08:28 +0100 Subject: [PATCH] Move SnapshotConfig class --- .../ProjectionSnapshotRepositoryInMemory.kt | 21 ----------------- .../libs/event/projection/SnapshotConfig.kt | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 src/main/kotlin/eventDemo/libs/event/projection/SnapshotConfig.kt diff --git a/src/main/kotlin/eventDemo/libs/event/projection/ProjectionSnapshotRepositoryInMemory.kt b/src/main/kotlin/eventDemo/libs/event/projection/ProjectionSnapshotRepositoryInMemory.kt index c383de7..fe5200f 100644 --- a/src/main/kotlin/eventDemo/libs/event/projection/ProjectionSnapshotRepositoryInMemory.kt +++ b/src/main/kotlin/eventDemo/libs/event/projection/ProjectionSnapshotRepositoryInMemory.kt @@ -10,27 +10,6 @@ import kotlinx.datetime.Clock import kotlinx.datetime.Instant import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentLinkedQueue -import kotlin.time.Duration -import kotlin.time.Duration.Companion.minutes - -data class SnapshotConfig( - /** - * Keep snapshot when is on the head of the queue cache - */ - val maxSnapshotCacheSize: Int = 20, - /** - * Keep snapshot when is newer of - * - * snapshot.date > now + maxSnapshotCacheTtl - */ - val maxSnapshotCacheTtl: Duration = 10.minutes, - /** - * Keep snapshot when version is this modulo - * - * snapshot.lastVersion % modulo == 1 - */ - val modulo: Int = 10, -) class ProjectionSnapshotRepositoryInMemory, P : Projection, ID : AggregateId>( private val eventStore: EventStore, diff --git a/src/main/kotlin/eventDemo/libs/event/projection/SnapshotConfig.kt b/src/main/kotlin/eventDemo/libs/event/projection/SnapshotConfig.kt new file mode 100644 index 0000000..2129da4 --- /dev/null +++ b/src/main/kotlin/eventDemo/libs/event/projection/SnapshotConfig.kt @@ -0,0 +1,23 @@ +package eventDemo.libs.event.projection + +import kotlin.time.Duration +import kotlin.time.Duration.Companion.minutes + +data class SnapshotConfig( + /** + * Keep snapshot when is on the head of the queue cache + */ + val maxSnapshotCacheSize: Int = 20, + /** + * Keep snapshot when is newer of + * + * snapshot.date > now + maxSnapshotCacheTtl + */ + val maxSnapshotCacheTtl: Duration = 10.minutes, + /** + * Keep snapshot when version is this modulo + * + * snapshot.lastVersion % modulo == 1 + */ + val modulo: Int = 10, +)