Is there any way to use an existing Jasync connect...
# komapper
d
Is there any way to use an existing Jasync connection to start a R2dbc komapper connection? We have a service we want to gradually migrate to Komapper and we don't want to have an extra connection pool open to the databases...
t
Try to wrap your existing connection with ConnectionFactory:
Copy code
val connectionFactory = object : ConnectionFactory {
    override fun create(): Publisher<out Connection> {
        // return existing connection
    }

    override fun getMetadata(): ConnectionFactoryMetadata {
        // ...
    }
}
val db = R2dbcDatabase(connectionFactory, H2R2dbcDialect())
d
How do I do this with a JASync connection? (I'm really not too familiar with r2dbc api, and the docs are almost inexistant...)
t
I am not familiar with JASync; doesn’t JASync Connection provide io.r2dbc.spi.Connection? You can convert io.r2dbc.spi.Connection to Publisher<out Connection> as followings:
Copy code
flowOf(connection).asPublisher()
It has it's own connection object w/o r2dbc