postgres-nio icon indicating copy to clipboard operation
postgres-nio copied to clipboard

Provide a ConnectionPool

Open fabianfett opened this issue 2 years ago • 9 comments

We should provide a ConnectionPool out of the box.

fabianfett avatar Mar 11 '22 15:03 fabianfett

Absolutely agreed.

Jerry-Carter avatar Mar 16 '22 13:03 Jerry-Carter

I have a very simple connection pool implementation which is an actor with dependencies on NIO, PostgresNIO, and Logging. Having the application pass in the PostgresConnection.Configuration would further simplify it. Typical usage is to initialize the actor, and then Checkout() and Release() database connections as required in the application.

Happy to donate it, but I would expect that better code exists elsewhere in the Vapor code base.

Jerry-Carter avatar Mar 17 '22 19:03 Jerry-Carter

Снимок экрана 2022-05-15 в 19 02 22 Can you help with this?

CyrilusK avatar May 15 '22 16:05 CyrilusK

I can also offer a connection pool for those interested: https://github.com/Outdooractive/PostgresConnectionPool

trasch avatar Apr 28 '23 08:04 trasch

For security purposes it would be great to support ephemeral database user credentials, generated by something like HashiCorp’s Vault. These credentials timeout and then need to be regenerated. When they change, the Connection Pool would need to automatically close or automatically handle getting the new credentials and updating the connection.

majortom64 avatar Sep 25 '23 15:09 majortom64

Work can be followed in the ConnectionPool milestone.

fabianfett avatar Oct 13 '23 13:10 fabianfett

@majortom64 your request is tracked as #431.

fabianfett avatar Oct 28 '23 20:10 fabianfett

We've released a PostgresClient implementation behind an SPI flag in the 1.19.0 release: https://github.com/vapor/postgres-nio/releases/tag/1.19.0

We would love to learn, if this solves your use-cases.

fabianfett avatar Oct 31 '23 11:10 fabianfett

I just implemented the _ConnectionPoolModule in the Oracle driver I'm working on. The API is very easy to understand imo. It actually surprised me how little I had to do to get everything working. Thanks for the great work @fabianfett!

lovetodream avatar Nov 13 '23 16:11 lovetodream