Closed petromir closed 3 years ago
You mean configuring ConnectionPool
with ConnectionFactories.get(ConnectionFactoryOptions.builder().option(DRIVER, "pool").option(PROTOCOL, "postgresql")…)
?
Do you have a suggestion? ConnectionFactories.get(…)
is part of the SPI and can only return ConnectionFactory
and not ConnectionPool
.
Suggested solution could be found here https://github.com/petromir/r2dbc-pool-idle-connection-issue/blob/master/src/main/java/com/example/demo/R2dbcPostgreSQLConfig.java#L45 I'm still not sure how this will work when the user wants to use a proxy, but I will have to try it soon as this what we are using in my regular job.
But isn't that basically what we already have:
Programmatic Configuration
ConnectionFactory connectionFactory = …; ConnectionPoolConfiguration configuration = ConnectionPoolConfiguration.builder(connectionFactory) .maxIdleTime(Duration.ofMillis(1000)) .maxSize(20) .build(); ConnectionPool pool = new ConnectionPool(configuration); Mono<Connection> connectionMono = pool.create(); // later Connection connection = …; Mono<Void> release = connection.close(); // released the connection back to the pool // application shutdown pool.dispose();
I think we can add a bit of comment to folks willing to read the docs to outline what connectionFactory
actually represents.
Thanks!
@mp911de During investigation of stale idle connections in
reactor-pool
, Simon Baslé noted an interesting problem regarding ConnectionFactory and ConnectionPool construction (https://github.com/reactor/reactor-pool/issues/136#issuecomment-834263342). In my opinion the documentation should be updated, so when people copy paste the examples they won't accidentally create 2 pools instead of one, as this results in 10 always open connections.