generic-pool
Advanced tools
Comparing version 3.4.2 to 3.5.0
# Change Log | ||
## [3.5.0] - January 17 2019 | ||
- update nodejs versions tested by travis | ||
- eviction iterator no longer stops when reaching end of object list #243 (@DiegoRBaquero) | ||
- fix #192 softIdleTimeoutMillis = -1 no longer triggers evictor to run #242 (@DiegoRBaquero) | ||
- fix #234 maxWaitingClients = 0 is no longer ignored #247 (@anupbaldawa) | ||
## [3.4.2] - Febuary 16 2018 | ||
@@ -177,3 +183,4 @@ - fix `pool.use` to resolve after user supplied function has finished. (@asannes) | ||
[unreleased]: https://github.com/coopernurse/node-pool/compare/v3.4.2...HEAD | ||
[unreleased]: https://github.com/coopernurse/node-pool/compare/v3.5.0...HEAD | ||
[3.5.0]: https://github.com/coopernurse/node-pool/compare/v3.4.2...v3.5.0 | ||
[3.4.2]: https://github.com/coopernurse/node-pool/compare/v3.4.1...v3.4.2 | ||
@@ -180,0 +187,0 @@ [3.4.1]: https://github.com/coopernurse/node-pool/compare/v3.4.0...v3.4.1 |
@@ -8,2 +8,3 @@ "use strict"; | ||
if ( | ||
config.softIdleTimeoutMillis > 0 && | ||
config.softIdleTimeoutMillis < idleTime && | ||
@@ -10,0 +11,0 @@ config.min < availableObjectsCount |
@@ -365,3 +365,3 @@ "use strict"; | ||
this._evictionIterator.reset(); | ||
break; | ||
continue; | ||
} | ||
@@ -441,2 +441,4 @@ | ||
if ( | ||
this.spareResourceCapacity < 1 && | ||
this._availableObjects.length < 1 && | ||
this._config.maxWaitingClients !== undefined && | ||
@@ -490,3 +492,3 @@ this._waitingClientsQueue.length >= this._config.maxWaitingClients | ||
isBorrowedResource(resource) { | ||
return this._resourceLoans.get(resource) !== undefined; | ||
return this._resourceLoans.has(resource); | ||
} | ||
@@ -493,0 +495,0 @@ |
@@ -75,3 +75,3 @@ "use strict"; | ||
if (opts.maxWaitingClients) { | ||
if (opts.maxWaitingClients !== undefined) { | ||
// @ts-ignore | ||
@@ -78,0 +78,0 @@ this.maxWaitingClients = parseInt(opts.maxWaitingClients, 10); |
{ | ||
"name": "generic-pool", | ||
"description": "Generic resource pooling for Node.JS", | ||
"version": "3.4.2", | ||
"version": "3.5.0", | ||
"author": "James Cooper <james@bitmechanic.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -102,3 +102,3 @@ [![build status](https://secure.travis-ci.org/coopernurse/node-pool.png)](http://travis-ci.org/coopernurse/node-pool) | ||
- `factory` : an object containing functions to create/destroy/test resources for the `Pool` | ||
- `opts` : an optional object/dictonary to allow configuring/altering behaviour the of the `Pool` | ||
- `opts` : an optional object/dictonary to allow configuring/altering behaviour of the `Pool` | ||
@@ -138,3 +138,3 @@ ```js | ||
- `evictionRunIntervalMillis`: How often to run eviction checks. Default: 0 (does not run). | ||
- `numTestsPerRun`: Number of resources to check each eviction run. Default: 3. | ||
- `numTestsPerEvictionRun`: Number of resources to check each eviction run. Default: 3. | ||
- `softIdleTimeoutMillis`: amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object evictor (if any), with the extra condition that at least "min idle" object instances remain in the pool. Default -1 (nothing can get evicted) | ||
@@ -141,0 +141,0 @@ - `idleTimeoutMillis`: the minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due to idle time. Supercedes `softIdleTimeoutMillis` Default: 30000 |
@@ -751,1 +751,64 @@ "use strict"; | ||
}); | ||
tap.test("evictor should not run when softIdleTimeoutMillis is -1", function( | ||
t | ||
) { | ||
const resourceFactory = new ResourceFactory(); | ||
const pool = createPool(resourceFactory, { | ||
evictionRunIntervalMillis: 10 | ||
}); | ||
pool | ||
.acquire() | ||
.then(res => pool.release(res)) | ||
.then(() => { | ||
return new Promise(res => setTimeout(res, 30)); | ||
}) | ||
.then(() => t.equal(resourceFactory.destroyed, 0)) | ||
.then(() => { | ||
utils.stopPool(pool); | ||
t.end(); | ||
}); | ||
}); | ||
tap.test("should respect when maxWaitingClients is set to 0 ", function(t) { | ||
let assertionCount = 0; | ||
const resourceFactory = new ResourceFactory(); | ||
const config = { | ||
max: 2, | ||
maxWaitingClients: 0 | ||
}; | ||
const pool = createPool(resourceFactory, config); | ||
const borrowedResources = []; | ||
t.equal(pool.size, 0); | ||
assertionCount += 1; | ||
pool | ||
.acquire() | ||
.then(function(obj) { | ||
borrowedResources.push(obj); | ||
t.equal(pool.size, 1); | ||
assertionCount += 1; | ||
}) | ||
.then(function() { | ||
return pool.acquire(); | ||
}) | ||
.then(function(obj) { | ||
borrowedResources.push(obj); | ||
t.equal(pool.size, 2); | ||
assertionCount += 1; | ||
}) | ||
.then(function() { | ||
return pool.acquire(); | ||
}) | ||
.then(function(obj) { | ||
// should not go in here | ||
t.equal(1, 2); | ||
}) | ||
.catch(error => { | ||
t.equal(error.message, "max waitingClients count exceeded"); | ||
t.end(); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97655
2377