https://kotlinlang.org logo
#komapper
Title
# komapper
d

dave08

02/16/2023, 1:08 PM
Is there a way to do a clean shutdown of an R2dbc connection pool that was was passed as a
ConnectionFactory
in
R2dbcDatabase(...)
? Like when shutting down a Ktor server in Kubernetes, will all the connections be closed automatically? Otherwise, I'd need some kind of
close()
to clean them up on
SIGTERM
or
SIGINT
.
t

Toshihiro Nakamura

02/16/2023, 11:39 PM
Komapper does not close pooled connections automatically. Do you use r2dbc-pool? This method may be helpful to you. https://github.com/r2dbc/r2dbc-pool/blob/v1.0.0.RELEASE/src/main/java/io/r2dbc/pool/ConnectionPool.java#L308
d

dave08

02/17/2023, 4:07 AM
Yeah, but there's no constructor in komapper that allows me to pass an instance of the pool.. I can only pass a connection factory and let komapper handle it...
So I don't have access to that method
t

Toshihiro Nakamura

02/17/2023, 1:05 PM
io.r2dbc.pool.ConnectionPool
is the subtype of
io.r2dbc.spi.ConnectionFactory
. So you can pass it to the R2dbcDatabase constructor. The
ConnectionFactory
managed by Komapper will be made available in the next version. https://github.com/komapper/komapper/pull/894
d

dave08

02/22/2023, 2:53 PM
Will this be released soon? Thanks 😃!
t

Toshihiro Nakamura

02/22/2023, 10:05 PM
Yes, we are releasing it this weekend.
140 Views