diff --git a/integrations/schemas/ort-configuration-schema.json b/integrations/schemas/ort-configuration-schema.json index ef003e059d821..aeca317b5b835 100644 --- a/integrations/schemas/ort-configuration-schema.json +++ b/integrations/schemas/ort-configuration-schema.json @@ -384,6 +384,24 @@ }, "parallelTransactions": { "type": "integer" + }, + "connectionTimeout": { + "type": "integer" + }, + "idleTimeout": { + "type": "integer" + }, + "keepaliveTime": { + "type": "integer" + }, + "maxLifetime": { + "type": "integer" + }, + "maximumPoolSize": { + "type": "integer" + }, + "minimumIdle": { + "type": "integer" } }, "required": [ diff --git a/model/src/main/kotlin/config/PostgresConnection.kt b/model/src/main/kotlin/config/PostgresConnection.kt index 54d8bc6fd6d91..29f78fa87eb0d 100644 --- a/model/src/main/kotlin/config/PostgresConnection.kt +++ b/model/src/main/kotlin/config/PostgresConnection.kt @@ -75,7 +75,45 @@ data class PostgresConnection( /** * The number of parallel transactions to use for the storage dispatcher. */ - val parallelTransactions: Int = 5 + val parallelTransactions: Int = 5, + + /** + * The maximum number of milliseconds to wait for connections from the pool. For details see the + * [Hikari documentation](https://github.com/brettwooldridge/HikariCP#frequently-used). + */ + val connectionTimeout: Long?, + + /** + * The maximum number of milliseconds a connection is allowed to sit idle in the pool. This requires that + * [minimumIdle] is set to a value lower than [maximumPoolSize]. For details see the + * [Hikari documentation](https://github.com/brettwooldridge/HikariCP#frequently-used). + */ + val idleTimeout: Long?, + + /** + * The frequency in milliseconds that the pool will attempt to keep an idle connection alive. Must be set to a value + * lower than [maxLifetime]. For details see the + * [Hikari documentation](https://github.com/brettwooldridge/HikariCP#frequently-used). + */ + val keepaliveTime: Long?, + + /** + * The maximum lifetime of a connection in milliseconds. For details see the + * [Hikari documentation](https://github.com/brettwooldridge/HikariCP#frequently-used). + */ + val maxLifetime: Long?, + + /** + * The maximum size of the connection pool. For details see the + * [Hikari documentation](https://github.com/brettwooldridge/HikariCP#frequently-used). + */ + val maximumPoolSize: Int?, + + /** + * The minimum number of idle connections that the pool tries to maintain. For details see the + * [Hikari documentation](https://github.com/brettwooldridge/HikariCP#frequently-used). + */ + val minimumIdle: Int? /** * TODO: Make additional parameters configurable, see: diff --git a/model/src/main/kotlin/utils/DatabaseUtils.kt b/model/src/main/kotlin/utils/DatabaseUtils.kt index 9c74fb11a9933..508496fa4ad35 100644 --- a/model/src/main/kotlin/utils/DatabaseUtils.kt +++ b/model/src/main/kotlin/utils/DatabaseUtils.kt @@ -73,6 +73,13 @@ object DatabaseUtils { schema = config.schema maximumPoolSize = maxPoolSize + connectionTimeout = config.connectionTimeout ?: connectionTimeout + idleTimeout = config.idleTimeout ?: idleTimeout + keepaliveTime = config.keepaliveTime ?: keepaliveTime + maxLifetime = config.maxLifetime ?: maxLifetime + maximumPoolSize = config.maximumPoolSize ?: maximumPoolSize + minimumIdle = config.minimumIdle ?: minimumIdle + val suffix = " - $applicationNameSuffix".takeIf { applicationNameSuffix.isNotEmpty() }.orEmpty() addDataSourceProperty("ApplicationName", "$ORT_FULL_NAME$suffix")