Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rotating connection details #291

Closed
tomalexander opened this issue May 16, 2018 · 1 comment
Closed

Add support for rotating connection details #291

tomalexander opened this issue May 16, 2018 · 1 comment

Comments

@tomalexander
Copy link

tomalexander commented May 16, 2018

It would be nice if the Pool supported rotating connection details. Our use-case would be using the hashicorp vault database secrets engine to generate postgres credentials on-the-fly. These credentials inherently have a limited life-span so when they expire we'd need to rotate them. As a work-around we were going to swap out the pool with a new pool but #290 prevents that.

One possible way to implement it, would be:

  1. expose a function to set the connection details
  2. when that function is called, all new calls to acquire() would return connections with the new connection details set
  3. as connections with the old details are returned to the pool they get discarded

I could see this also being useful for fail-overs but thats not our use-case so idk

@elprans
Copy link
Member

elprans commented May 17, 2018

Possibly the simplest solution would be to factor out connection spec into a Pool method and allow subclassing it. Then we could add a recycle() method to the pool to indicate that all open connections should expire upon release() to trigger graceful failover.

elprans added a commit that referenced this issue Jun 4, 2018
The new `Pool.cycle()` method expires all currently open connections,
so they would be replaced with fresh ones on the next `acquire()`
attempt.

The new `Pool.set_connect_args()` allows changing the connection
arguments for an existing pool instance.  Coupled with `cycle()`, it
allows adapting the pool to the new environment conditions without
having to replace the pool instance.

Fixes: #291
elprans added a commit that referenced this issue Jun 4, 2018
The new `Pool.cycle()` method expires all currently open connections,
so they would be replaced with fresh ones on the next `acquire()`
attempt.

The new `Pool.set_connect_args()` allows changing the connection
arguments for an existing pool instance.  Coupled with `cycle()`, it
allows adapting the pool to the new environment conditions without
having to replace the pool instance.

Fixes: #291
elprans added a commit that referenced this issue Jun 4, 2018
The new `Pool.cycle()` method expires all currently open connections,
so they would be replaced with fresh ones on the next `acquire()`
attempt.

The new `Pool.set_connect_args()` allows changing the connection
arguments for an existing pool instance.  Coupled with `cycle()`, it
allows adapting the pool to the new environment conditions without
having to replace the pool instance.

Fixes: #291
elprans added a commit that referenced this issue Jun 5, 2018
The new `Pool.expire_connections()` method expires all currently
open connections, so they would be replaced with fresh ones on
the next `acquire()` attempt.

The new `Pool.set_connect_args()` allows changing the connection
arguments for an existing pool instance.  Coupled with
`expire_connections()`, it allows adapting the pool to the new
environment conditions without having to replace the pool
instance.

Fixes: #291
elprans added a commit that referenced this issue Jun 5, 2018
The new `Pool.expire_connections()` method expires all currently
open connections, so they would be replaced with fresh ones on
the next `acquire()` attempt.

The new `Pool.set_connect_args()` allows changing the connection
arguments for an existing pool instance.  Coupled with
`expire_connections()`, it allows adapting the pool to the new
environment conditions without having to replace the pool
instance.

Fixes: #291
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants