generic-pool
Advanced tools
Comparing version 3.1.5 to 3.1.6
# Change Log | ||
## [3.1.6] - December 28 2016 | ||
- fix #173 where pool would not attempt to dispense reources upon `pool.destroy` | ||
- fix some out of date readme section | ||
- fix test warning for unhandled rejection on dispense | ||
## [3.1.5] - December 20 2016 | ||
@@ -148,3 +153,4 @@ - fix drain code to correctly wait on borrowed resources (@drew-r) | ||
======= | ||
[unreleased]: https://github.com/coopernurse/node-pool/compare/v3.1.5...HEAD | ||
[unreleased]: https://github.com/coopernurse/node-pool/compare/v3.1.6...HEAD | ||
[3.1.6]: https://github.com/coopernurse/node-pool/compare/v3.1.5...v3.1.6 | ||
[3.1.5]: https://github.com/coopernurse/node-pool/compare/v3.1.4...v3.1.5 | ||
@@ -151,0 +157,0 @@ [3.1.4]: https://github.com/coopernurse/node-pool/compare/v3.1.3...v3.1.4 |
@@ -458,2 +458,4 @@ 'use strict' | ||
this._destroy(pooledResource) | ||
this._dispense() | ||
return this._Promise.resolve() | ||
@@ -460,0 +462,0 @@ } |
{ | ||
"name": "generic-pool", | ||
"description": "Generic resource pooling for Node.JS", | ||
"version": "3.1.5", | ||
"version": "3.1.6", | ||
"author": "James Cooper <james@bitmechanic.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -304,2 +304,5 @@ [![build status](https://secure.travis-ci.org/coopernurse/node-pool.png)](http://travis-ci.org/coopernurse/node-pool) | ||
// How many many more resources can the pool manage/create | ||
pool.spareResourceCapacity | ||
// returns number of resources in the pool regardless of | ||
@@ -312,2 +315,5 @@ // whether they are free or in use | ||
// number of resources that are currently acquired by userland code | ||
pool.borrowed | ||
// returns number of callers waiting to acquire a resource | ||
@@ -314,0 +320,0 @@ pool.pending |
@@ -566,16 +566,75 @@ 'use strict' | ||
// Invalid release | ||
pool.release({}) | ||
pool.release({}).catch(function (err) { | ||
t.match(err.message, /Resource not currently part of this pool/) | ||
}).then(function () { | ||
t.equal(pool.available, 0) | ||
t.equal(pool.borrowed, 1) | ||
// Valid release | ||
pool.release(obj).catch(t.error) | ||
t.equal(pool.available, 1) | ||
t.equal(pool.borrowed, 0) | ||
utils.stopPool(pool) | ||
t.end() | ||
}) | ||
}).catch(t.threw) | ||
}) | ||
tap.test('validate acquires object from the pool', function (t) { | ||
const pool = createPool({ | ||
create: function () { | ||
return Promise.resolve({ id: 'validId' }) | ||
}, | ||
validate: function (resource) { | ||
return Promise.resolve(true) | ||
}, | ||
destroy: function (client) {}, | ||
max: 1 | ||
}) | ||
pool.acquire() | ||
.then(function (obj) { | ||
t.equal(pool.available, 0) | ||
t.equal(pool.borrowed, 1) | ||
pool.release(obj) | ||
utils.stopPool(pool) | ||
t.end() | ||
}) | ||
.catch(t.threw) | ||
}) | ||
// Valid release | ||
tap.test('release to pool should work', function (t) { | ||
const pool = createPool({ | ||
create: function () { | ||
return Promise.resolve({ id: 'validId' }) | ||
}, | ||
validate: function (resource) { | ||
return Promise.resolve(true) | ||
}, | ||
destroy: function (client) {}, | ||
max: 1 | ||
}) | ||
pool.acquire() | ||
.then(function (obj) { | ||
t.equal(pool.available, 0) | ||
t.equal(pool.borrowed, 1) | ||
t.equal(pool.pending, 1) | ||
pool.release(obj) | ||
t.equal(pool.available, 1) | ||
t.equal(pool.borrowed, 0) | ||
}) | ||
.catch(t.threw) | ||
pool.acquire() | ||
.then(function (obj) { | ||
t.equal(pool.available, 0) | ||
t.equal(pool.borrowed, 1) | ||
t.equal(pool.pending, 0) | ||
pool.release(obj) | ||
utils.stopPool(pool) | ||
t.end() | ||
}).catch(t.threw) | ||
}) | ||
.catch(t.threw) | ||
}) | ||
tap.test('validate acquires object from the pool', function (t) { | ||
tap.test('destroy should redispense', function (t) { | ||
const pool = createPool({ | ||
@@ -596,2 +655,12 @@ create: function () { | ||
t.equal(pool.borrowed, 1) | ||
t.equal(pool.pending, 1) | ||
pool.destroy(obj) | ||
}) | ||
.catch(t.threw) | ||
pool.acquire() | ||
.then(function (obj) { | ||
t.equal(pool.available, 0) | ||
t.equal(pool.borrowed, 1) | ||
t.equal(pool.pending, 0) | ||
pool.release(obj) | ||
@@ -598,0 +667,0 @@ utils.stopPool(pool) |
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
87659
2085
364