MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / keepingPool

Function keepingPool

__tests__/query-pool.test.ts:275–288  ·  view source on GitHub ↗

A pool whose workers are light enough to keep, each answering with its own number.

(size: number, ready: (index: number) => boolean | null = () => true)

Source from the content-addressed store, hash-verified

273
274 /** A pool whose workers are light enough to keep, each answering with its own number. */
275 function keepingPool(size: number, ready: (index: number) => boolean | null = () => true) {
276 const workers: FakeWorker[] = [];
277 const pool = new QueryPool({
278 root: '/x', size, idleShrinkMs: 5, idleKeepBytes: light,
279 createWorker: () => {
280 const index = workers.length;
281 const worker = new FakeWorker(() => ({ result: ok(`worker ${index}`) }), ready(index));
282 worker.heldBytes = light;
283 workers.push(worker);
284 return worker;
285 },
286 });
287 return { pool, workers };
288 }
289
290 it('answers the first call after idle on the worker already running, starting none', async () => {
291 const { pool, workers } = keepingPool(2);

Callers 1

query-pool.test.tsFile · 0.85

Calls 3

readyFunction · 0.85
pushMethod · 0.80
okFunction · 0.70

Tested by

no test coverage detected