From bd90de001a5777bfe7a32306e95a49f9eae8370e Mon Sep 17 00:00:00 2001 From: dufrannea <680334+dufrannea@users.noreply.github.com> Date: Thu, 25 Feb 2021 09:08:53 +0100 Subject: [PATCH] Allows to override jdbc connectionString (#596) Also, bumps version Co-authored-by: Arnaud Dufranne --- build.sbt | 2 +- core/src/main/scala/com/criteo/cuttle/Database.scala | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 11af46d6f..cbd820c10 100644 --- a/build.sbt +++ b/build.sbt @@ -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" diff --git a/core/src/main/scala/com/criteo/cuttle/Database.scala b/core/src/main/scala/com/criteo/cuttle/Database.scala index dfb4f9cdd..229ac6d8a 100644 --- a/core/src/main/scala/com/criteo/cuttle/Database.scala +++ b/core/src/main/scala/com/criteo/cuttle/Database.scala @@ -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 { @@ -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