coopernurse / node-pool

Generic resource pooling for node.js
2.37k stars 258 forks source link

Suggestion on softEvictConnections #306

Open terryzhan0211 opened 1 year ago

terryzhan0211 commented 1 year ago

Hi, I want to implement a "soft evict" in my code, similar to how it's implemented in HikariCP: https://javadoc.io/doc/com.zaxxer/HikariCP/latest/com/zaxxer/hikari/HikariPoolMXBean.html#softEvictConnections() https://github.com/brettwooldridge/HikariCP/blob/dev/src/main/java/com/zaxxer/hikari/pool/HikariPool.java#L364. It involves evicting currently idle connections from the pool and marking active (in-use) connections for eviction when they are returned to the pool. Currently, I have my own custom implementation where I iterate through the set that stores all connections in the pool. However, the set _allObjects, which stores all connections, is currently a private variable and has not been exported and thus requires 'as any' to use in typescript. It works but as this logic should ideally be implemented at the pool level, can we expect an official API to be added in a future release, or perhaps consider exporting the allObjects set? I would appreciate any suggestions you may have. Thanks for creating this library!