MCPcopy Create free account
hub / github.com/coopernurse/node-pool / _createResource

Method _createResource

lib/Pool.js:317–340  ·  view source on GitHub ↗

* @private

()

Source from the content-addressed store, hash-verified

315 * @private
316 */
317 _createResource() {
318 // An attempt to create a resource
319 const factoryPromise = this._factory.create();
320 const wrappedFactoryPromise = this._Promise
321 .resolve(factoryPromise)
322 .then(resource => {
323 const pooledResource = new PooledResource(resource);
324 this._allObjects.add(pooledResource);
325 this._addPooledResourceToAvailableObjects(pooledResource);
326 });
327
328 this._trackOperation(wrappedFactoryPromise, this._factoryCreateOperations)
329 .then(() => {
330 this._dispense();
331 // Stop bluebird complaining about this side-effect only handler
332 // - a promise was created in a handler but was not returned from it
333 // https://goo.gl/rRqMUw
334 return null;
335 })
336 .catch(reason => {
337 this.emit(FACTORY_CREATE_ERROR, reason);
338 this._dispense();
339 });
340 }
341
342 /**
343 * @private

Callers 2

_dispenseMethod · 0.95
_ensureMinimumMethod · 0.95

Calls 5

_trackOperationMethod · 0.95
_dispenseMethod · 0.95
createMethod · 0.65
resolveMethod · 0.45

Tested by

no test coverage detected