Skip to content

Commit

Permalink
Restore binary backwards compatibility of SchemaConfig.
Browse files Browse the repository at this point in the history
The idea is to restore binary backwards compatibility of `SchemaConfig`.

`SchemaConfig.Keyspace` is restored for that purposes and the method is
added to convert it to `KeyspaceConfig`.

The class itself is marked as deprecated and is planned to be removed in
a next non-binary-compatible release.

This is a smaller PR split from #586 for easier review.
  • Loading branch information
rtar committed Mar 19, 2024
1 parent 8cd160c commit bb5258d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object CreateSchema {
}

for {
_ <- createKeyspace(config.keyspace)
_ <- createKeyspace(config.keyspace.toKeyspaceConfig)
result <- createTables1
} yield result
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.evolutiongaming.kafka.journal.eventual.cassandra

import com.evolutiongaming.scassandra.ReplicationStrategyConfig
import pureconfig.ConfigReader
import pureconfig.generic.semiauto.deriveReader

final case class SchemaConfig(
keyspace: KeyspaceConfig = KeyspaceConfig.default,
keyspace: SchemaConfig.Keyspace = SchemaConfig.Keyspace.default,
journalTable: String = "journal",
metadataTable: String = "metadata",
metaJournalTable: String = "metajournal",
Expand All @@ -21,8 +22,28 @@ object SchemaConfig {

implicit val configReaderSchemaConfig: ConfigReader[SchemaConfig] = deriveReader

@deprecated(since = "3.3.9", message = "Use [[KeyspaceConfig]] instead")
final case class Keyspace(
name: String = "journal",
replicationStrategy: ReplicationStrategyConfig = ReplicationStrategyConfig.Default,
autoCreate: Boolean = true) {

def toKeyspaceConfig: KeyspaceConfig = KeyspaceConfig(
name = this.name,
replicationStrategy = this.replicationStrategy,
autoCreate = this.autoCreate
)

@deprecated(since = "3.2.2", message = "Use [[KeyspaceConfig]] instead")
type Keyspace = Nothing
}


@deprecated(since = "3.3.9", message = "Use [[KeyspaceConfig]] instead")
object Keyspace {

val default: Keyspace = Keyspace()


implicit val configReaderKeyspace: ConfigReader[Keyspace] = deriveReader
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object SetupSchema {
def createSchema(implicit cassandraSync: CassandraSync[F]) = CreateSchema(config)

for {
cassandraSync <- CassandraSync.of[F](config.keyspace, config.locksTable, origin)
cassandraSync <- CassandraSync.of[F](config.keyspace.toKeyspaceConfig, config.locksTable, origin)
ab <- createSchema(cassandraSync)
(schema, fresh) = ab
settings <- SettingsCassandra.of[F](schema.setting, origin, consistencyConfig.toCassandraConsistencyConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CreateSchemaSpec extends AnyFunSuite {
test("not create keyspace and tables") {
val config = SchemaConfig.default.copy(
autoCreate = false,
keyspace = KeyspaceConfig.default.copy(autoCreate = false)
keyspace = SchemaConfig.Keyspace.default.copy(autoCreate = false)
)
val createSchema = CreateSchema[F](config, createKeyspace, createTables)
val (database, (schema, fresh)) = createSchema.run(Database.empty).value
Expand All @@ -43,7 +43,7 @@ class CreateSchemaSpec extends AnyFunSuite {

test("create part of the tables") {
val config = SchemaConfig.default.copy(
keyspace = KeyspaceConfig.default.copy(autoCreate = false)
keyspace = SchemaConfig.Keyspace.default.copy(autoCreate = false)
)
val initialState = Database.empty.copy(
keyspaces = List("journal"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SchemaConfigSpec extends AnyFunSuite with Matchers {
test("apply from config") {
val config = ConfigFactory.parseURL(getClass.getResource("schema.conf"))
val expected = SchemaConfig(
keyspace = KeyspaceConfig(
keyspace = SchemaConfig.Keyspace(
name = "keyspace",
replicationStrategy = ReplicationStrategyConfig.Simple(3),
autoCreate = false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object ReadEventsApp extends IOApp {

val eventualCassandraConfig = EventualCassandraConfig(
schema = SchemaConfig(
keyspace = KeyspaceConfig(
keyspace = SchemaConfig.Keyspace(
name = "keyspace",
autoCreate = false),
autoCreate = false),
Expand Down

0 comments on commit bb5258d

Please sign in to comment.