Skip to content
This repository was archived by the owner on Dec 30, 2019. It is now read-only.

Add interface to generic-pool getters#61

Closed
j1banez wants to merge 1 commit intobrianc:masterfrom
j1banez:add-genericpool-getters-interface
Closed

Add interface to generic-pool getters#61
j1banez wants to merge 1 commit intobrianc:masterfrom
j1banez:add-genericpool-getters-interface

Conversation

@j1banez
Copy link

@j1banez j1banez commented Jun 7, 2017

If one needs to access pool state (total size, available objects and in use objects) it has to access the genericPool getters like this:

const Pool = require('pg-pool');

const pool = new Pool();

const size = pool.pool.getPoolSize();
const available = pool.pool.availableObjetcsCount();
const borrowed = pool.pool.inUseObjectsCount();

While it works it is a bit risky cause pool.pool is an internal generic-pool 2.4.3 instance thus we have no control to when generic-pool will be updated and when the api will break, and it will break because generic-pool 3's getters has been renamed.

So I suggest with this PR to add pg-pool getters that wrap generic-pool getters in order to safely access the pool state,
When pg-pool will update his version of 'generic-pool' we will just need to update the pg-pool getters
to use the new names of the generic-pool getters and it will be transparent with no breaking changes for the users.

@sibedge
Copy link

sibedge commented Jun 20, 2017

This PR could be part of it: #59

as it does the same, specifically for one flag.

@brianc
Copy link
Owner

brianc commented Aug 7, 2017

generic pool has been removed as a dependency, so all the getters are now directly on pool and anything documented is considered part of the public API and wont be changing between major versions. So...yay! 💃

If you or your company benefit from node-postgres and have the means, please consider supporting my work on Patreon.

@brianc brianc closed this Aug 7, 2017
@j1banez j1banez deleted the add-genericpool-getters-interface branch August 7, 2017 06:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants