From 7636648cd4202f1064562a06518464bfc8cb28a0 Mon Sep 17 00:00:00 2001 From: pierrebruninmaif Date: Thu, 21 Dec 2023 15:51:53 +0100 Subject: [PATCH] fix pg client must be a shared instance --- src/main/java/fr/maif/automate/MainVerticle.kt | 1 + src/main/java/fr/maif/automate/commons/Configuration.kt | 5 +++-- src/main/resources/application.conf | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/maif/automate/MainVerticle.kt b/src/main/java/fr/maif/automate/MainVerticle.kt index fc2f3d4..2a30224 100644 --- a/src/main/java/fr/maif/automate/MainVerticle.kt +++ b/src/main/java/fr/maif/automate/MainVerticle.kt @@ -135,6 +135,7 @@ class MainVerticle : AbstractVerticle() { Some("port" to pgConfig.port), Some("database" to pgConfig.database), Some("url" to url), + Some("max_pool_size" to pgConfig.maxPoolSize), pgConfig.username.map { "username" to it }, pgConfig.password.map { "password" to it } ).flatMap { it.toList() } diff --git a/src/main/java/fr/maif/automate/commons/Configuration.kt b/src/main/java/fr/maif/automate/commons/Configuration.kt index e582e9c..59e3887 100644 --- a/src/main/java/fr/maif/automate/commons/Configuration.kt +++ b/src/main/java/fr/maif/automate/commons/Configuration.kt @@ -104,7 +104,7 @@ data class LetSEncryptConfig(val server: String, val accountId: String) { } } -data class PostgresConfig(val host: String, val port: Int, val database: String, val username: Option, val password: Option) { +data class PostgresConfig(val host: String, val port: Int, val database: String, val username: Option, val password: Option, val maxPoolSize: Int) { companion object { fun load(config: Config): PostgresConfig = PostgresConfig( @@ -112,7 +112,8 @@ data class PostgresConfig(val host: String, val port: Int, val database: String, 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") ) } } diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index dc1aed8..d3f3d1b 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -52,6 +52,8 @@ postgres { username = ${?POSTGRESQL_ADDON_USER} password = "password" password = ${?POSTGRESQL_ADDON_PASSWORD} + maxPoolSize = 2 + maxPoolSize = ${?POSTGRESQL_ADDON_MAX_POOL_SIZE} } clevercloud {