node-pg-pool icon indicating copy to clipboard operation
node-pg-pool copied to clipboard

Implement 'release' event and 'activeCount' property.

Open PrimeJunta opened this issue 6 years ago • 4 comments

Implements feature request from https://github.com/brianc/node-pg-pool/issues/124 .

PrimeJunta avatar May 20 '19 10:05 PrimeJunta

Hi @brianc, in case you think the suggestion from the issue I reported is worth addressing, here's an implementation. Thanks for the work you're doing and don't worry, I won't be mad if you decline it.

PrimeJunta avatar May 20 '19 10:05 PrimeJunta

Hey thanks for the PR! My suggestion would be if you only want to track the active count that we just use an increment/decrement on a this._activeCount = 0 field instead of keeping an array and adding/removing items to it every time we add/remove an active client. What do you think?

brianc avatar May 20 '19 15:05 brianc

I have no objection. I implemented it that way to maintain consistency with the way you track idle and total clients, and also because I thought there might be a scenario where you'd want to know exactly which clients are checked out -- e.g. if you're debugging a mysterious client leak and track it by flagging each client with something that identifies the process that checked it out. I might be overthinking it however; a simple counter would certainly suffice for the actual scenarios I had in mind.

Would you like me to update the PR or shall you do it yourself?

PrimeJunta avatar May 20 '19 15:05 PrimeJunta

I've addressed the change requests @charmander made. If you'd like me to switch from the array to a simple int counter, let me know and I'll make that change also.

PrimeJunta avatar May 27 '19 12:05 PrimeJunta