X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fhttp-client-pool%2Fsrc%2Fpool.ts;h=3d64150a8af14c161c4a005a044ad2b003bacad0;hb=8db00db4ef10ceeb63dcbd7a85be68b9a70e5911;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..3d64150a 100644 --- a/examples/typescript/http-client-pool/src/pool.ts +++ b/examples/typescript/http-client-pool/src/pool.ts @@ -1,6 +1,6 @@ import { fileURLToPath } from 'node:url' import { dirname, extname, join } from 'node:path' -import { FixedThreadPool, availableParallelism } from 'poolifier' +import { DynamicThreadPool, availableParallelism } from 'poolifier' import { type WorkerData, type WorkerResponse } from './types.js' const workerFile = join( @@ -8,7 +8,8 @@ const workerFile = join( `worker${extname(fileURLToPath(import.meta.url))}` ) -export const httpClientPool = new FixedThreadPool( +export const httpClientPool = new DynamicThreadPool( + 1, availableParallelism(), workerFile, { @@ -17,7 +18,7 @@ export const httpClientPool = new FixedThreadPool( concurrency: 8 }, errorHandler: (e: Error) => { - console.error(e) + console.error('Thread worker error:', e) } } )