Skip to content

Commit 2e71379

Browse files
committed
improve docs; add deprecation to a factory method
1 parent a42ca3f commit 2e71379

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

persistence-cassandra/src/main/scala/com/evolutiongaming/kafka/flow/cassandra/CassandraPersistence.scala

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ import scala.util.Try
1717
trait CassandraPersistence[F[_], S] extends PersistenceModule[F, S]
1818
object CassandraPersistence {
1919

20-
/** Creates schema in Cassandra if not there yet. */
20+
/** Creates schema in Cassandra if not there yet. Uses default names for all Cassandra tables:
21+
* - for keys see [[com.evolutiongaming.kafka.flow.key.CassandraKeys.DefaultTableName]]
22+
* - for snapshots see [[com.evolutiongaming.kafka.flow.snapshot.CassandraSnapshots.DefaultTableName]]
23+
* - for journals see [[com.evolutiongaming.kafka.flow.journal.CassandraJournals.DefaultTableName]]
24+
*/
2125
def withSchemaF[F[_]: Async, S](
2226
session: scassandra.CassandraSession[F],
2327
sync: CassandraSync[F],
@@ -33,7 +37,10 @@ object CassandraPersistence {
3337
def snapshots = _snapshots
3438
}
3539

36-
/** Creates schema in Cassandra if not there yet
40+
/** Creates schema in Cassandra if not there yet. Uses default names for all Cassandra tables:
41+
* - for keys see [[com.evolutiongaming.kafka.flow.key.CassandraKeys.DefaultTableName]]
42+
* - for snapshots see [[com.evolutiongaming.kafka.flow.snapshot.CassandraSnapshots.DefaultTableName]]
43+
* - for journals see [[com.evolutiongaming.kafka.flow.journal.CassandraJournals.DefaultTableName]]
3744
*
3845
* This method uses the same `JsonCodec[Try]` as `JournalParser` does to simplify defining the basic application. if
3946
* \@consistencyConfig is present then applies ConsistencyConfig.Read for all read queries and
@@ -51,12 +58,16 @@ object CassandraPersistence {
5158
withSchemaF(session, sync, consistencyOverrides, keysSegments)
5259
}
5360

54-
/** Deletes all data in Cassandra */
61+
/** Deletes all data in Cassandra. Uses default names for all Cassandra tables:
62+
* - for keys see [[com.evolutiongaming.kafka.flow.key.CassandraKeys.DefaultTableName]]
63+
* - for snapshots see [[com.evolutiongaming.kafka.flow.snapshot.CassandraSnapshots.DefaultTableName]]
64+
* - for journals see [[com.evolutiongaming.kafka.flow.journal.CassandraJournals.DefaultTableName]]
65+
*/
5566
def truncate[F[_]: Monad](
5667
session: scassandra.CassandraSession[F],
5768
sync: CassandraSync[F]
5869
): F[Unit] =
5970
CassandraKeys.truncate(session, sync, CassandraKeys.DefaultTableName) *>
60-
CassandraJournals.truncate(session, sync) *>
71+
CassandraJournals.truncate(session, sync, CassandraJournals.DefaultTableName) *>
6172
CassandraSnapshots.truncate(session, sync, CassandraSnapshots.DefaultTableName)
6273
}

persistence-cassandra/src/main/scala/com/evolutiongaming/kafka/flow/journal/CassandraJournals.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,20 @@ object CassandraJournals {
8585
): F[JournalDatabase[F, KafkaKey, ConsumerRecord[String, ByteVector]]] =
8686
withSchema(session, sync, ConsistencyOverrides.none, DefaultTableName)
8787

88+
@deprecated(
89+
"Use the version with an explicit table name. This exists to preserve binary compatibility until the next major release",
90+
since = "6.1.3"
91+
)
8892
def truncate[F[_]: Monad](
8993
session: CassandraSession[F],
9094
sync: CassandraSync[F],
91-
tableName: String,
92-
): F[Unit] = JournalSchema.of(session, sync, tableName).truncate
95+
): F[Unit] = truncate(session, sync, DefaultTableName)
9396

9497
def truncate[F[_]: Monad](
9598
session: CassandraSession[F],
9699
sync: CassandraSync[F],
97-
): F[Unit] = truncate(session, sync, DefaultTableName)
100+
tableName: String = DefaultTableName,
101+
): F[Unit] = JournalSchema.of(session, sync, tableName).truncate
98102

99103
// we cannot use DecodeRow here because TupleToHeader is effectful
100104
protected def decode[F[_]: MonadThrow](key: KafkaKey, row: Row): F[ConsumerRecord[String, ByteVector]] = {

0 commit comments

Comments
 (0)