Closed amarshall closed 3 years ago
But why?
What's wrong with ConnectionPool.new...
?
It requires updating every reference to the Pool held everywhere, which in some cases is cumbersome.
Ok, then I think I have a problem with the naming. Once something is shutdown, it should not be reused. Perhaps we need a reload
method which is used instead of shutdown
? Can you explain the higher-level use case you are trying to solve? Reloading connections when DNS changes, or similar?
Once something is shutdown, it should not be reused. Perhaps we need a reload method which is used instead of shutdown?
“Restart” seems the obvious name for first shutting-down, then “starting” to put back into a usable state (which is what this method does). So while I disagree that “once shutdown it should not be reused”, I’m not here to bikeshed and so will defer to you on naming semantics.
Can you explain the higher-level use case you are trying to solve?
Similar to the referenced previous issue: all connections in the pool need to all be recreated after forking.
Got it, thanks for the context, now I understand what we are trying to achieve. I think I prefer reload
. Can you implement it without adding a new method to TimedStack, i.e. shutdown(reload=false, &block)
?
Sure, just in TimedStack or also in ConnectionPool?
I think the public API should be more explicit: ConnectionPool#reload
with RDoc that explains the use case.
See updated commits.
Checking in to see if there’s any further feedback as it’s been a bit, thanks.
Out of curiosity, what type of connections are you pooling? I ask because many Ruby connection libraries automatically recycle the connection if they detect a PID change (i.e. after a fork).
In this particular case we’re using the redis gem. It does detect PID-change, but raises (src).
Please update the changelog and readme.
Updated.
Well done, thanks for your hard work and patience!
This method is highly appreciated. Thanks for working on it!
The implementation of shutdown from #27 does not actually provide for a way for the pool to re-create connections, only render the pool unusable. This implements such a behavior. A new method is added so as to not change the existing behavior of
shutdown
.