Skip to content

Commit

Permalink
Merge pull request #2294 from hongwei1/develop
Browse files Browse the repository at this point in the history
feature/add the hikari configurations in default.props
  • Loading branch information
simonredfern committed Oct 16, 2023
2 parents 13a07f4 + ff2449c commit eee1be0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
echo kafka.akka.timeout = 9 >> obp-api/src/main/resources/props/test.default.props
echo remotedata.timeout = 10 >> obp-api/src/main/resources/props/test.default.props
echo api_instance_id = 1 >> obp-api/src/main/resources/props/test.default.props
echo allow_oauth2_login=true >> obp-api/src/main/resources/props/test.default.props
echo oauth2.jwk_set.url=https://www.googleapis.com/oauth2/v3/certs >> obp-api/src/main/resources/props/test.default.props
Expand Down
8 changes: 8 additions & 0 deletions obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ connector=star
#connector=proxy
#connector=...

#OBP uses Hikari as the default database connection pool. OBP supports the following 5 configurations at the moment.
#https://github.com/brettwooldridge/HikariCP#frequently-used
#hikari.connectionTimeout=
#hikari.maximumPoolSize=
#hikari.idleTimeout=
#hikari.keepaliveTime=
#hikari.maxLifetime=

## if connector = star, then need to set which connectors will be used. For now, obp support rest, akka, kafka. If you set kafka, then you need to start the kafka server.
starConnector_supported_types=mapped,internal

Expand Down
25 changes: 24 additions & 1 deletion obp-api/src/main/scala/bootstrap/liftweb/CustomDBVendor.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package bootstrap.liftweb

import code.api.util.APIUtil
import com.zaxxer.hikari.pool.ProxyConnection
import com.zaxxer.hikari.{HikariConfig, HikariDataSource}

import java.sql.{Connection}
import java.sql.Connection
import net.liftweb.common.{Box, Full, Logger}
import net.liftweb.db.ConnectionManager
import net.liftweb.util.ConnectionIdentifier
Expand All @@ -26,6 +27,28 @@ class CustomDBVendor(driverName: String,

object HikariDatasource {
val config = new HikariConfig()

val connectionTimeout = APIUtil.getPropsAsLongValue("hikari.connectionTimeout")
val maximumPoolSize = APIUtil.getPropsAsIntValue("hikari.maximumPoolSize")
val idleTimeout = APIUtil.getPropsAsLongValue("hikari.idleTimeout")
val keepaliveTime = APIUtil.getPropsAsLongValue("hikari.keepaliveTime")
val maxLifetime = APIUtil.getPropsAsLongValue("hikari.maxLifetime")

if(connectionTimeout.isDefined){
config.setConnectionTimeout(connectionTimeout.head)
}
if(maximumPoolSize.isDefined){
config.setMaximumPoolSize(maximumPoolSize.head)
}
if(idleTimeout.isDefined){
config.setIdleTimeout(idleTimeout.head)
}
if(keepaliveTime.isDefined){
config.setKeepaliveTime(keepaliveTime.head)
}
if(maxLifetime.isDefined){
config.setMaxLifetime(maxLifetime.head)
}

(dbUser, dbPassword) match {
case (Full(user), Full(pwd)) =>
Expand Down
6 changes: 5 additions & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
### Most recent changes at top of file
```
Date Commit Action
22/09/2023 752ff04b Added props db.maxPoolSize, default is 10.
13/10/2023 d87c99d8 Added props hikari.connectionTimeout, default is from hikari.
Added props hikari.maximumPoolSize, default is from hikari.
Added props hikari.idleTimeout, default is from hikari.
Added props hikari.keepaliveTime, default is from hikari.
Added props hikari.maxLifetime, default is from hikari.
24/08/2023 bcb8fcfd Added props expectedOpenFuturesPerService, default is 100.
16/08/2023 4d8dfa66 Added props short_endpoint_timeout, default is 1.
Added props medium_endpoint_timeout, default is 7.
Expand Down

0 comments on commit eee1be0

Please sign in to comment.