r2dbc/r2dbc-pool

Allow updating the password after the initialisation of Connection Pool

vsantwana opened this issue · 2 comments

Feature Request

Is your feature request related to a problem? Please describe

Currently I am working on migrating my Database from using static username and password to dynamic credentials, more specifically IAM DB authentication. The Auth Token that is used as a password expires every 15 minutes. We use R2DBC Connection Pool to get the connection pool and subsequently the connection. As I understand it so far, there is no way to update the password provided to the pool after the pool has been initialised.
My current way of doing things is that I have a wrapper around my ConnectionPool object, which has a background thread that closes the current connection pool and initialises a new one every 13 minutes. There are two problems with the approach that I am doing:

  1. It does not allow me to leverage the full power of Connection Pools
  2. It can lead to errors when I am trying to close the connection pool and some connections are actively running during that time.

Since the password would be needed again, when the connection pool has to scale up or has to restart for a reason, one solution could be to trust that the connection is correct and update the connection pool only when the new connections start failing, but it increases the number of errors in my application.

Describe the solution you'd like

  1. Add another option to ConnectionFactoryOptions, with the name link scheduledUpdate which takes a callback to update other options taken by the factory.

Describe alternatives you've considered

[See Description]

Teachability, Documentation, Adoption, Migration Strategy

Looks like a duplicate of pgjdbc/r2dbc-postgresql#529. The pool works on top of a ConnectionFactory and a factory does not have public API to reconfigure it.

Thanks @mp911de for pointing it to me. Closing this issue.