postgres-nio
postgres-nio copied to clipboard
Provide a ConnectionPool
We should provide a ConnectionPool out of the box.
Absolutely agreed.
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.

I can also offer a connection pool for those interested: https://github.com/Outdooractive/PostgresConnectionPool
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.
Work can be followed in the ConnectionPool milestone.
@majortom64 your request is tracked as #431.
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.
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!