Closed skeggse closed 9 years ago
Why not just call pool.end()
when you want to exit your program?
Because sometimes when I'm writing scripts I just want to unref
. You're right, pool.end()
is a good way to go when I'm building something I want to deploy. As I said, nice to have.
Gotcha. I mainly asked because in my opinion, .ref
and .unref
are antipatterns in Node.js and I really don't want to add something like that here, especially since it would be a challenge, as implementing something like that on the pool is much harder than it seems if we actually want to keep connections around for re-use (since we'd have to fully unref all the stuff in a connection when it's released and undo that when it's required every time for it to work properly).
After further thought, I agree: this feature is more trouble than it's worth.
Add
Pool#ref
andPool#unref
methods, which allow the program to automatically exit if the pool is inactive (either it has no connections, or the connections are all idle/not acquired).Nice to have.