X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fhttp-client-pool%2Fsrc%2Fpool.ts;h=83bec2fd5ac1dc501a4c6b8cc68ca56721d170c5;hb=HEAD;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..83bec2fd 100644 --- a/examples/typescript/http-client-pool/src/pool.ts +++ b/examples/typescript/http-client-pool/src/pool.ts @@ -1,23 +1,26 @@ -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, { enableTasksQueue: true, tasksQueueOptions: { - concurrency: 8 + concurrency: 8, }, errorHandler: (e: Error) => { - console.error(e) - } + console.error('Thread worker error:', e) + }, } )