Skip to content

Commit

Permalink
refactor(persistence): use with(...) to initialize persistence objects
Browse files Browse the repository at this point in the history
  • Loading branch information
bas-kirill committed Aug 29, 2024
1 parent 0e3bad5 commit 3d42cc6
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ class PersistenceConfiguration {
const val MAXIMUM_POOL_SIZE = 25
}

@Bean
fun hikariConfig() = with(HikariConfig()) {
username = postgresUser
password = postgresPassword
driverClassName = "org.postgresql.Driver"
jdbcUrl = postgresDsn
this
}

@Bean
fun dataSource(): DataSource {
val hikariConfig = HikariConfig()
hikariConfig.username = postgresUser
hikariConfig.password = postgresPassword
hikariConfig.driverClassName = "org.postgresql.Driver"
hikariConfig.jdbcUrl = postgresDsn
val hikariDatasource = HikariDataSource(hikariConfig)
// 25 is a good enough data pool size, it is a database in a container after all
hikariDatasource.maximumPoolSize = MAXIMUM_POOL_SIZE
return hikariDatasource
fun dataSource(hikariConfig: HikariConfig): DataSource = with(HikariDataSource(hikariConfig)) {
maximumPoolSize = MAXIMUM_POOL_SIZE
this
}

@Bean
Expand Down

0 comments on commit 3d42cc6

Please sign in to comment.