Open ghost opened 4 years ago
For what it is worth, I have implemented this functionality in Slonik.
https://github.com/gajus/slonik#slonik-usage-end-connection-pool
Of course, the majority of the work is still done by pg-pool. Slonik simply enables this functionality by patching pg-pool.
pool.end() processes the queries in the active connections but then drops all other pending queries, there really needs to be an option to also process all pending queries or end() needs to be changed to finish pending queries before shutting down. Other libraries like the mongodb-node driver finish pending queries with the close() method rather than drop pending queries. Users most likely want queries to finish after queuing them up and get a callback for when those are done