Skip to content

Commit

Permalink
Allows to override jdbc connectionString (#596)
Browse files Browse the repository at this point in the history
Also, bumps version

Co-authored-by: Arnaud Dufranne <[email protected]>
  • Loading branch information
dufrannea and Arnaud Dufranne authored Feb 25, 2021
1 parent fd19e9f commit bd90de0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ val devMode = settingKey[Boolean]("Some build optimization are applied in devMod
val writeClasspath = taskKey[File]("Write the project classpath to a file.")
val yarnInstall = taskKey[Unit]("Install yarn dependencies")

val VERSION = "0.12.1"
val VERSION = "0.12.2"

lazy val catsCore = "1.6.1"
lazy val circe = "0.11.1"
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/scala/com/criteo/cuttle/Database.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ case class DBLocation(host: String, port: Int)
* @param username JDBC username
* @param password JDBC password
*/
case class DatabaseConfig(locations: Seq[DBLocation], database: String, username: String, password: String)
case class DatabaseConfig(locations: Seq[DBLocation], database: String, username: String, password: String, jdbcString: Option[String] = None)

/** Utilities for [[DatabaseConfig]]. */
object DatabaseConfig {
Expand Down Expand Up @@ -186,8 +186,9 @@ object Database {
import com.criteo.cuttle.ThreadPools.Implicits.doobieContextShift

val locationString = dbConfig.locations.map(dbLocation => s"${dbLocation.host}:${dbLocation.port}").mkString(",")
val jdbcString = s"jdbc:mariadb://$locationString/${dbConfig.database}" +
"?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&failOverReadOnly=false&rewriteBatchedStatements=true"

val jdbcString = dbConfig.jdbcString.getOrElse(s"jdbc:mariadb://$locationString/${dbConfig.database}" +
"?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&failOverReadOnly=false&rewriteBatchedStatements=true")

for {
connectThreadPool <- ThreadPools.doobieConnectThreadPoolResource
Expand Down

0 comments on commit bd90de0

Please sign in to comment.