mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
configurable idle timeout on pooled clients
This commit is contained in:
parent
aa63f50437
commit
c16c7f619d
@ -12,5 +12,7 @@ module.exports = {
|
||||
rows: 0,
|
||||
//number of connections to use in connection pool
|
||||
//0 will disable connection pooling
|
||||
poolSize: 10
|
||||
poolSize: 10,
|
||||
//duration of node-pool timeout
|
||||
poolIdleTimeout: 30000
|
||||
}
|
||||
|
||||
@ -42,7 +42,8 @@ var makeConnectFunction = function(ClientConstructor) {
|
||||
destroy: function(client) {
|
||||
client.end();
|
||||
},
|
||||
max: defaults.poolSize
|
||||
max: defaults.poolSize,
|
||||
idleTimeoutMillis: defaults.poolIdleTimeout
|
||||
});
|
||||
return pool.acquire(cb);
|
||||
}
|
||||
|
||||
12
test/integration/connection-pool/idle-timeout-tests.js
Normal file
12
test/integration/connection-pool/idle-timeout-tests.js
Normal file
@ -0,0 +1,12 @@
|
||||
var helper = require(__dirname + '/test-helper');
|
||||
|
||||
helper.pg.defaults.poolIdleTimeout = 200;
|
||||
|
||||
test('idle timeout', function() {
|
||||
helper.pg.connect(helper.connectionString(), assert.calls(function(err, client) {
|
||||
assert.isNull(err);
|
||||
client.query('SELECT NOW()');
|
||||
//just let this one time out
|
||||
//test will hang if pool doesn't timeout
|
||||
}));
|
||||
});
|
||||
@ -6,7 +6,7 @@ helper.pg.defaults.password = helper.args.password;
|
||||
helper.pg.defaults.database = helper.args.database;
|
||||
helper.pg.defaults.port = helper.args.port;
|
||||
helper.pg.defaults.host = helper.args.host;
|
||||
|
||||
helper.pg.defaults.poolIdleTimeout = 100;
|
||||
var args = {
|
||||
user: helper.args.user,
|
||||
password: helper.args.password,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user