X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fhttp-client-pool%2Fsrc%2Fpool.ts;h=6988372eb1e4e07683fd129f8a2ea2b9ea0d40e2;hb=4aef9c4526473c4d4699be96fb382933eafb40d3;hp=139f3fb963e4fdfd454efc9de79fede213deacbb;hpb=5ba0cd3c9bdb6479399aa77f45321ac72183f135;p=poolifier.git diff --git a/examples/typescript/http-client-pool/src/pool.ts b/examples/typescript/http-client-pool/src/pool.ts index 139f3fb9..6988372e 100644 --- a/examples/typescript/http-client-pool/src/pool.ts +++ b/examples/typescript/http-client-pool/src/pool.ts @@ -1,14 +1,17 @@ -import { fileURLToPath } from 'node:url' import { dirname, extname, join } from 'node:path' -import { FixedThreadPool, availableParallelism } from 'poolifier' -import { type WorkerData, type WorkerResponse } from './types.js' +import { fileURLToPath } from 'node:url' + +import { availableParallelism, DynamicThreadPool } from 'poolifier' + +import type { WorkerData, WorkerResponse } from './types.js' const workerFile = join( dirname(fileURLToPath(import.meta.url)), `worker${extname(fileURLToPath(import.meta.url))}` ) -export const httpClientPool = new FixedThreadPool( +export const httpClientPool = new DynamicThreadPool( + 0, availableParallelism(), workerFile, { @@ -17,7 +20,7 @@ export const httpClientPool = new FixedThreadPool( concurrency: 8 }, errorHandler: (e: Error) => { - console.error(e) + console.error('Thread worker error:', e) } } )