From f6a74eb4a07eac7ebae8b208a4371e63e78660b2 Mon Sep 17 00:00:00 2001 From: Tarun Kothuri Date: Tue, 11 Aug 2015 13:11:29 -0400 Subject: [PATCH] add option `poolReturnToHead` which is passed through to genericPool add option `poolReturnToHead` to facilitate reduction of pool size after demand recedes. As the current round robin check now keeps on touching all the connections and never lets them expire under decent traffic. --- lib/defaults.js | 3 +++ lib/pool.js | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/defaults.js b/lib/defaults.js index 9f5687b05..eb445af6a 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -33,6 +33,9 @@ var defaults = module.exports = { //frequeny to check for idle clients within the client pool reapIntervalMillis: 1000, + // re-use most recent connections, allowing older connections to be reaped. + poolReturnToHead: false, + //pool log function / boolean poolLog: false, diff --git a/lib/pool.js b/lib/pool.js index b85a67383..d4f76e0ff 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -20,6 +20,7 @@ var pools = { max: clientConfig.poolSize || defaults.poolSize, idleTimeoutMillis: clientConfig.poolIdleTimeout || defaults.poolIdleTimeout, reapIntervalMillis: clientConfig.reapIntervalMillis || defaults.reapIntervalMillis, + returnToHead: clientConfig.poolReturnToHead || defaults.poolReturnToHead, log: clientConfig.poolLog || defaults.poolLog, create: function(cb) { var client = new pools.Client(clientConfig);