Skip to content

Commit 4399f43

Browse files
getDate > new Date. Add trackBorrowed Connections config.
1 parent 1e7855c commit 4399f43

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

lib/Pool.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,19 @@ Pool.prototype.borrowedConnections = function () {
226226
};
227227

228228
Pool.prototype._borrowAdd = function _borrowAdd(connection) {
229-
connection.borrowedAt = getDate();
229+
if (!this.config.trackBorrowedConnections)
230+
{
231+
return;
232+
}
233+
connection.borrowedAt = new Date();
230234
this._borrowedConnections.push(connection);
231235
};
232236

233237
Pool.prototype._borrowRemove = function _borrowAdd(connection) {
238+
if (!this.config.trackBorrowedConnections)
239+
{
240+
return;
241+
}
234242
spliceConnection(this._borrowedConnections, connection);
235243
};
236244

lib/PoolConfig.js

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ function PoolConfig(options) {
2020
this.queueLimit = (options.queueLimit === undefined)
2121
? 0
2222
: Number(options.queueLimit);
23+
this.trackBorrowedConnections = (options.trackBorrowedConnections === undefined)
24+
? true
25+
: Boolean(options.trackBorrowedConnections);
2326
}
2427

2528
PoolConfig.prototype.newConnectionConfig = function newConnectionConfig() {

lib/PoolConnection.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ inherits(PoolConnection, Connection);
88
function PoolConnection(pool, options) {
99
Connection.call(this, options);
1010
this._pool = pool;
11-
this.borrowedAt = getDate(); //initialise variable upfront for performance
11+
this.borrowedAt = new Date(); //initialise variable upfront for performance
1212

1313
//why: so user can set this to 'longterm' if they don't expect to release it.
1414
//eventually, the getConnection function can support the borrowTerm as a parameter

0 commit comments

Comments
 (0)