MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / run

Method run

extensions/pooling/src/pooling.ts:262–274  ·  view source on GitHub ↗

* Run the task with an acquired resource from the pool. If task is completed * successfully, the resource is returned to the pool. Otherwise, the * resource is destroyed. * * @param task - A function that accepts a resource and returns a Promise.

(
    task: (resource: T) => ValueOrPromise<void>,
    requestCtx: Context = this.context,
  )

Source from the content-addressed store, hash-verified

260 * @param task - A function that accepts a resource and returns a Promise.
261 */
262 async run(
263 task: (resource: T) => ValueOrPromise<void>,
264 requestCtx: Context = this.context,
265 ) {
266 const resource = await this.acquire(requestCtx);
267 try {
268 await task(resource);
269 } catch (err) {
270 await this.destroy(resource);
271 throw err;
272 }
273 await this.release(resource);
274 }
275}
276
277/**

Callers 1

Calls 4

acquireMethod · 0.95
destroyMethod · 0.95
releaseMethod · 0.95
taskFunction · 0.85

Tested by

no test coverage detected