Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows to override jdbc connectionString #596

Merged
merged 1 commit into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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