From 3dcd233e6a4ddfbcc24085ce57dd4b785192e52e Mon Sep 17 00:00:00 2001 From: Ruslans Tarasovs Date: Thu, 15 Feb 2024 11:24:48 +0200 Subject: [PATCH] Rename SnapshotStoreFlat to SnapshotStore. The reason behind this is that there won't be a flat counterpart of the store. It will be the only one. --- .../kafka/journal/SnapshotStoreAdapter.scala | 4 +- .../cassandra/SnapshotCassandra.scala | 8 +-- .../kafka/journal/SnapshotStoreFlat.scala | 58 ------------------- 3 files changed, 6 insertions(+), 64 deletions(-) delete mode 100644 snapshot/src/main/scala/com/evolutiongaming/kafka/journal/SnapshotStoreFlat.scala diff --git a/persistence/src/main/scala/akka/persistence/kafka/journal/SnapshotStoreAdapter.scala b/persistence/src/main/scala/akka/persistence/kafka/journal/SnapshotStoreAdapter.scala index 6fa00768a..636e78dbe 100644 --- a/persistence/src/main/scala/akka/persistence/kafka/journal/SnapshotStoreAdapter.scala +++ b/persistence/src/main/scala/akka/persistence/kafka/journal/SnapshotStoreAdapter.scala @@ -38,7 +38,7 @@ object SnapshotStoreAdapter { ): Resource[F, SnapshotStoreAdapter[F]] = { def adapter( - store: SnapshotStoreFlat[F] + store: SnapshotStore[F] )(implicit snapshotSerializer: SnapshotSerializer[F, A], snapshotReadWrite: SnapshotReadWrite[F, A]) = SnapshotStoreAdapter(store, toKey, origin) @@ -47,7 +47,7 @@ object SnapshotStoreAdapter { } yield adapter(store)(snapshotSerializer, snapshotReadWrite) } - def apply[F[_]: Monad: Fail, A](store: SnapshotStoreFlat[F], toKey: ToKey[F], origin: Option[Origin])(implicit + def apply[F[_]: Monad: Fail, A](store: SnapshotStore[F], toKey: ToKey[F], origin: Option[Origin])(implicit snapshotSerializer: SnapshotSerializer[F, A], snapshotReadWrite: SnapshotReadWrite[F, A] ): SnapshotStoreAdapter[F] = diff --git a/snapshot-cassandra/src/main/scala/com/evolutiongaming/kafka/journal/snapshot/cassandra/SnapshotCassandra.scala b/snapshot-cassandra/src/main/scala/com/evolutiongaming/kafka/journal/snapshot/cassandra/SnapshotCassandra.scala index ec2aff141..c9252b0d1 100644 --- a/snapshot-cassandra/src/main/scala/com/evolutiongaming/kafka/journal/snapshot/cassandra/SnapshotCassandra.scala +++ b/snapshot-cassandra/src/main/scala/com/evolutiongaming/kafka/journal/snapshot/cassandra/SnapshotCassandra.scala @@ -18,7 +18,7 @@ object SnapshotCassandra { config: SnapshotCassandraConfig, origin: Option[Origin], cassandraClusterOf: CassandraClusterOf[F] - ): Resource[F, SnapshotStoreFlat[F]] = { + ): Resource[F, SnapshotStore[F]] = { def store(implicit cassandraCluster: CassandraCluster[F], cassandraSession: CassandraSession[F]) = of(config.schema, origin, config.consistencyConfig, config.numberOfSnapshots) @@ -36,7 +36,7 @@ object SnapshotCassandra { origin: Option[Origin], consistencyConfig: CassandraConsistencyConfig, numberOfSnapshots: Int - ): F[SnapshotStoreFlat[F]] = + ): F[SnapshotStore[F]] = for { schema <- SetupSnapshotSchema[F](schemaConfig, origin, consistencyConfig) statements <- Statements.of[F](schema, consistencyConfig) @@ -44,8 +44,8 @@ object SnapshotCassandra { private sealed abstract class Main - def apply[F[_]: MonadThrow](statements: Statements[F], numberOfSnapshots: Int): SnapshotStoreFlat[F] = { - new Main with SnapshotStoreFlat[F] { + def apply[F[_]: MonadThrow](statements: Statements[F], numberOfSnapshots: Int): SnapshotStore[F] = { + new Main with SnapshotStore[F] { def save(key: Key, snapshot: SnapshotRecord[EventualPayloadAndType]): F[Unit] = { statements.selectMetadata(key).flatMap { diff --git a/snapshot/src/main/scala/com/evolutiongaming/kafka/journal/SnapshotStoreFlat.scala b/snapshot/src/main/scala/com/evolutiongaming/kafka/journal/SnapshotStoreFlat.scala deleted file mode 100644 index 05d5e1cef..000000000 --- a/snapshot/src/main/scala/com/evolutiongaming/kafka/journal/SnapshotStoreFlat.scala +++ /dev/null @@ -1,58 +0,0 @@ -package com.evolutiongaming.kafka.journal - -import com.evolutiongaming.kafka.journal.eventual.EventualPayloadAndType - -/** Snapshot storage for Kafka Journal. - * - * Uses `Key` instead of `persistenceId`, similar to [[ReplicatedJournalFlat]] - * and [[EventualJournal]]. - */ -trait SnapshotStoreFlat[F[_]] { - - /** Save snapshot for a specific key. - * - * @param key - * Unique identifier of a journal snapshot is done for. - * @param snapshot - * Journal snapshot including sequence number and some metadata. - */ - def save(key: Key, snapshot: SnapshotRecord[EventualPayloadAndType]): F[Unit] - - /** Loads a snapshot for a given key and selection criteria. - * - * If several snapshots are found using a passed selection criteria for a - * specific key, then the last one (i.e. with a latest `SeqNr`) is returned. - * - * @param key - * Unique identifier of a journal snapshot was done for. - * @param criteria - * Criteria to use. - */ - def load(key: Key, criteria: SnapshotSelectionCriteria): F[Option[SnapshotRecord[EventualPayloadAndType]]] - - /** Deletes all snapshots for a given key and selection criteria. - * - * If several snapshots are found using a passed selection criteria for a - * specific key, then all of them are deleted. - * - * @param key - * Unique identifier of a journal snapshot was done for. - * @param criteria - * Criteria to use. - */ - def delete(key: Key, criteria: SnapshotSelectionCriteria): F[Unit] - - /** Deletes a snapshot for a given key and sequence number. - * - * The method returns the same as - * `load(key, SnapshotSelectionCriteria.one(seqNr))`, - * but additional optimizations might be possible. - * - * @param key - * Unique identifier of a journal snapshot was done for. - * @param seqNr - * Sequence number to be deleted. - */ - def delete(key: Key, seqNr: SeqNr): F[Unit] - -}