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

Method clear

lib/Pool.js:619–636  ·  view source on GitHub ↗

* Forcibly destroys all available resources regardless of timeout. Intended to be * invoked as part of a drain. Does not prevent the creation of new * resources as a result of subsequent calls to acquire. * * Note that if factory.min > 0 and the pool isn't "draining", the pool will des

()

Source from the content-addressed store, hash-verified

617 *
618 */
619 clear() {
620 const reflectedCreatePromises = Array.from(
621 this._factoryCreateOperations
622 ).map(reflector);
623
624 // wait for outstanding factory.create to complete
625 return this._Promise.all(reflectedCreatePromises).then(() => {
626 // Destroy existing resources
627 // @ts-ignore
628 for (const resource of this._availableObjects) {
629 this._destroy(resource);
630 }
631 const reflectedDestroyPromises = Array.from(
632 this._factoryDestroyOperations
633 ).map(reflector);
634 return reflector(this._Promise.all(reflectedDestroyPromises));
635 });
636 }
637
638 /**
639 * Waits until the pool is ready.

Callers 4

GH-159-test.jsFile · 0.80
utils.jsFile · 0.80

Calls 1

_destroyMethod · 0.95

Tested by

no test coverage detected