Skip to content

Commit

Permalink
Review feedbacks - schemaType no longer part of conf
Browse files Browse the repository at this point in the history
  • Loading branch information
debasishg committed Jul 1, 2021
1 parent b06f9d5 commit 822ce45
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
3 changes: 0 additions & 3 deletions core/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,6 @@ jdbc-durable-state-store {
batchSize = 500
# New states are retrieved (polled) with this interval.
refreshInterval = "1s"
# can be H2, POSTGRES
# schemaType = H2
schemaType = Postgres

tables {
state {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,6 @@ class DurableStateTableConfiguration(config: Config) {
private val cfg = config.getConfig("tables.state")
val refreshInterval: FiniteDuration = config.asFiniteDuration("refreshInterval")
val batchSize: Int = config.getInt("batchSize")
val schemaType: String = {
val s = config.getString("schemaType")
if (s != "H2" && s != "Postgres")
throw new IllegalArgumentException(s"Schema type [$s] not supported. Has to be one of H2 or Postgres")
else s
}
val tableName: String = cfg.getString("tableName")
val schemaName: Option[String] = cfg.asStringOption("schemaName")
val columnNames: DurableStateTableColumnNames = new DurableStateTableColumnNames(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,28 @@
package akka.persistence.jdbc.state

import slick.jdbc.{ JdbcProfile, SetParameter }
import slick.jdbc.H2Profile
import slick.jdbc.MySQLProfile
import slick.jdbc.OracleProfile
import slick.jdbc.PostgresProfile
import slick.jdbc.SQLServerProfile
import akka.persistence.jdbc.config.DurableStateTableConfiguration

class DurableStateQueries(val profile: JdbcProfile, override val durableStateTableCfg: DurableStateTableConfiguration)
extends DurableStateTables {
import profile.api._

lazy val sequenceNextValUpdater = durableStateTableCfg.schemaType match {
private def slickProfileToSchemaType(profile: JdbcProfile): String =
profile match {
case PostgresProfile => "Postgres"
case MySQLProfile => "MySQL"
case OracleProfile => "Oracle"
case SQLServerProfile => "SqlServer"
case H2Profile => "H2"
case _ => throw new IllegalArgumentException(s"Unknown JdbcProfile $profile encountered")
}

lazy val sequenceNextValUpdater = slickProfileToSchemaType(profile) match {
case "H2" => new H2SequenceNextValUpdater(profile)
case "Postgres" => new PostgresSequenceNextValUpdater(profile)
case _ => ???
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ abstract class StateSpecBase(val config: Config, schemaType: SchemaType)

val customConfig = ConfigFactory.parseString(s"""
jdbc-durable-state-store {
schemaType = ${schemaType.toString}
batchSize = 200
refreshInterval = 500.milliseconds
durable-state-sequence-retrieval {
Expand Down

0 comments on commit 822ce45

Please sign in to comment.