Node-Socket-Pool
Socket connection pool for Node
Install
npm install node-socket-pool
or
yarn add node-socket-pool
Usage
Get a client
;// in async function// or promisepool.getResource.then.catch
Options
host: string;port: number;// 最多维持连接数maxActive?: number;// 最多保留空闲连接数maxIdle?: number;// Socket连接最长空闲时间(毫秒)(超过时间后将返回资源池)maxIdleTime?: number;// pool中没有资源返回时,最大等待时间(毫秒)maxWait?: number;
Release
client.release;
or
pool.returnResourceclient;
client will auto return to idle resource pool if no data transportation for a time up to maxIdleTime option