Skip to content

Commit

Permalink
fix pg client must be a shared instance
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrebruninmaif committed Dec 21, 2023
1 parent 57476e7 commit 396ab61
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/fr/maif/automate/MainVerticle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class MainVerticle : AbstractVerticle() {
Some("port" to pgConfig.port),
Some("database" to pgConfig.database),
Some("url" to url),
Some("initial_pool_size" to 1),
Some("max_pool_size" to pgConfig.maxPoolSize),
pgConfig.username.map { "username" to it },
pgConfig.password.map { "password" to it }
).flatMap { it.toList() }
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/fr/maif/automate/commons/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ data class LetSEncryptConfig(val server: String, val accountId: String) {
}
}

data class PostgresConfig(val host: String, val port: Int, val database: String, val username: Option<String>, val password: Option<String>) {
data class PostgresConfig(val host: String, val port: Int, val database: String, val username: Option<String>, val password: Option<String>, val maxPoolSize: Int) {
companion object {
fun load(config: Config): PostgresConfig =
PostgresConfig(
host = config.getString("postgres.host"),
port = config.getInt("postgres.port"),
database = config.getString("postgres.database"),
username = Option(config.getString("postgres.username")),
password = Option(config.getString("postgres.password"))
password = Option(config.getString("postgres.password")),
maxPoolSize = config.getInt("postgres.maxPoolSize")
)
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ postgres {
username = ${?POSTGRESQL_ADDON_USER}
password = "password"
password = ${?POSTGRESQL_ADDON_PASSWORD}
maxPoolSize = 3
maxPoolSize = ${?POSTGRESQL_ADDON_MAX_POOL_SIZE}
}

clevercloud {
Expand Down

0 comments on commit 396ab61

Please sign in to comment.