generic-pool
Advanced tools
Comparing version 3.0.0-alpha.2 to 3.0.0-alpha.3
@@ -15,2 +15,3 @@ 'use strict' | ||
const FACTORY_CREATE_ERROR = 'factoryCreateError' | ||
const FACTORY_DESTROY_ERROR = 'factoryDestroyError' | ||
@@ -178,3 +179,7 @@ class Pool extends EventEmitter { | ||
destroyOp.then(() => { | ||
destroyOp | ||
.catch((reason) => { | ||
this.emit(FACTORY_DESTROY_ERROR, reason) | ||
}) | ||
.then(() => { | ||
this._factoryDestroyOperations.delete(destroyOp) | ||
@@ -389,7 +394,8 @@ }) | ||
}) | ||
.catch((err) => { | ||
.catch((reason) => { | ||
this._factoryCreateOperations.delete(factoryPromise) | ||
this.emit(FACTORY_CREATE_ERROR, err) | ||
this.emit(FACTORY_CREATE_ERROR, reason) | ||
this._dispense() | ||
}) | ||
.then() | ||
} | ||
@@ -476,3 +482,3 @@ | ||
if (loan === undefined) { | ||
return | ||
return this._Promise.reject(new Error('Resource not currently part of this pool')) | ||
} | ||
@@ -489,2 +495,3 @@ | ||
this._dispense() | ||
return this._Promise.resolve() | ||
} | ||
@@ -506,3 +513,3 @@ | ||
if (loan === undefined) { | ||
return | ||
return this._Promise.reject(new Error('Resource not currently part of this pool')) | ||
} | ||
@@ -516,2 +523,3 @@ | ||
this._destroy(pooledResource) | ||
return this._Promise.resolve() | ||
} | ||
@@ -529,3 +537,3 @@ | ||
/** | ||
* Disallow any new requests and let the request backlog dissapate. | ||
* Disallow any new acquire calls and let the request backlog dissapate. | ||
* Resolves once all resources are returned to pool and available... | ||
@@ -532,0 +540,0 @@ * @returns {Promise} |
{ | ||
"name": "generic-pool", | ||
"description": "Generic resource pooling for Node.JS", | ||
"version": "3.0.0-alpha.2", | ||
"version": "3.0.0-alpha.3", | ||
"author": "James Cooper <james@bitmechanic.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -172,2 +172,4 @@ [![build status](https://secure.travis-ci.org/coopernurse/node-pool.png)](http://travis-ci.org/coopernurse/node-pool) | ||
and returns a `Promise`. This promise will resolve once the `resource` is accepted by the pool, or reject if the pool is unable to accept the `resource` for any reason (e.g `resource` is not a resource or object that came from the pool). If you do not care the outcome it is safe to ignore this promise. | ||
### pool.destroy | ||
@@ -179,4 +181,6 @@ | ||
- `resource`: a previously borrow resource | ||
- `resource`: a previously borrowed resource | ||
and returns a `Promise`. This promise will resolve once the `resource` is accepted by the pool, or reject if the pool is unable to accept the `resource` for any reason (e.g `resource` is not a resource or object that came from the pool). If you do not care the outcome it is safe to ignore this promise. | ||
### pool.on | ||
@@ -186,5 +190,7 @@ | ||
`factoryCreateError` : emitted when a promise returned by `factory.create` is rejected. If this event has no listeners then the `error` will be silently discarded | ||
- `factoryCreateError` : emitted when a promise returned by `factory.create` is rejected. If this event has no listeners then the `error` will be silently discarded | ||
- `error`: whatever `reason` the promise was rejected with. | ||
- `err`: whatever `reason` the promise was rejected with. | ||
- `factoryDestroyError` : emitted when a promise returned by `factory.destroy` is rejected. If this event has no listeners then the `error` will be silently discarded | ||
- `error`: whatever `reason` the promise was rejected with. | ||
@@ -191,0 +197,0 @@ ## Draining |
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
76976
1851
371