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

Function getPooledValue

extensions/pooling/src/pooling.ts:99–120  ·  view source on GitHub ↗
(
  poolingService: PoolingService<T> | Pool<T>,
  requestCtx?: Context,
)

Source from the content-addressed store, hash-verified

97 * @param requestCtx - Request context
98 */
99export async function getPooledValue<T>(
100 poolingService: PoolingService<T> | Pool<T>,
101 requestCtx?: Context,
102): Promise<PooledValue<T>> {
103 let value: T;
104 if (poolingService instanceof PoolingService) {
105 value = await poolingService.acquire(requestCtx);
106 } else {
107 value = await poolingService.acquire();
108 }
109 const pool =
110 poolingService instanceof PoolingService
111 ? poolingService.pool
112 : poolingService;
113 return {
114 pool,
115 value,
116 async release() {
117 return poolingService.release(value);
118 },
119 };
120}
121
122/**
123 * A singleton service to maintain a pool of resources. This pool service can

Callers 1

valueMethod · 0.90

Calls 1

acquireMethod · 0.65

Tested by 1

valueMethod · 0.72