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 33c569c
Show file tree
Hide file tree
Showing 3 changed files with 10 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("min_pool_size" to pgConfig.minPoolSize),
Some("max_pool_size" to pgConfig.maxPoolSize),
pgConfig.username.map { "username" to it },
pgConfig.password.map { "password" to it }
).flatMap { it.toList() }
Expand Down
6 changes: 4 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,17 @@ 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 minPoolSize: Int, 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")),
minPoolSize = config.getInt("postgres.minPoolSize"),
maxPoolSize = config.getInt("postgres.maxPoolSize")
)
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ postgres {
username = ${?POSTGRESQL_ADDON_USER}
password = "password"
password = ${?POSTGRESQL_ADDON_PASSWORD}
minPoolSize = 1
minPoolSize = ${?POSTGRESQL_ADDON_MIN_POOL_SIZE}
maxPoolSize = 3
maxPoolSize = ${?POSTGRESQL_ADDON_MAX_POOL_SIZE}
}

clevercloud {
Expand Down

0 comments on commit 33c569c

Please sign in to comment.