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

Method _destroy

lib/Pool.js:132–151  ·  view source on GitHub ↗
(pooledResource)

Source from the content-addressed store, hash-verified

130 }
131
132 _destroy(pooledResource) {
133 // FIXME: do we need another state for "in destruction"?
134 pooledResource.invalidate();
135 this._allObjects.delete(pooledResource);
136 // NOTE: this maybe very bad promise usage?
137 const destroyPromise = this._factory.destroy(pooledResource.obj);
138 const wrappedDestroyPromise = this._config.destroyTimeoutMillis
139 ? this._Promise.resolve(this._applyDestroyTimeout(destroyPromise))
140 : this._Promise.resolve(destroyPromise);
141
142 this._trackOperation(
143 wrappedDestroyPromise,
144 this._factoryDestroyOperations
145 ).catch(reason => {
146 this.emit(FACTORY_DESTROY_ERROR, reason);
147 });
148
149 // TODO: maybe ensuring minimum pool size should live outside here
150 this._ensureMinimum();
151 }
152
153 _applyDestroyTimeout(promise) {
154 const timeoutPromise = new this._Promise((resolve, reject) => {

Callers 4

_testOnBorrowMethod · 0.95
_evictMethod · 0.95
destroyMethod · 0.95
clearMethod · 0.95

Calls 6

_applyDestroyTimeoutMethod · 0.95
_trackOperationMethod · 0.95
_ensureMinimumMethod · 0.95
invalidateMethod · 0.80
destroyMethod · 0.65
resolveMethod · 0.45

Tested by

no test coverage detected