Hi, when configuring Ktor with Exposed ORM, the Hi...
# exposed
h
Hi, when configuring Ktor with Exposed ORM, the Hikari CP is frequently used. Many tutorials about the Hikari configuration show the following setup:
Copy code
private fun hikari(): HikariDataSource {
    val config = HikariConfig()
    config.driverClassName = "your db driver"
    config.jdbcUrl = "your jdbcUrl"
    config.maximumPoolSize = 3
    config.isAutoCommit = false //1
    config.transactionIsolation = "TRANSACTION_REPEATABLE_READ" //2
    config.validate()
    return HikariDataSource(config)
}
I see
config.maximumPoolSize
often set to 3. I am not sure why it is specifically set to 3 but understand the idea (that is described in the Hikari Wiki page here). On the other hand, what I really don't understand are commands
config.isAutoCommit = false
(1) and
config.transactionIsolation = "TRANSACTION_REPEATABLE_READ"
(2). Why are these two settings suggested when using Ktor with Exposed and not just sticking to default values?
r
There is a good documentation provided by HikariCP author (about config): https://github.com/brettwooldridge/HikariCP#gear-configuration-knobs-baby
a
@hawklike did you by any chance find out why //1 is used with value = false in these tutorials? I’m trying to understand it too and the docu did not shed too much light on it. (At least in the current state of my knowledge about this stuff 🙂 )
h
@albrechtroehm IMO it is because every Exposed query is within a transaction, which at the end commits the changes automatically. But that's my guess only.
224 Views