Commit | Line | Data |
---|---|---|
11856b30 JB |
1 | import { fileURLToPath } from 'node:url' |
2 | import { dirname, extname, join } from 'node:path' | |
3 | import { FixedThreadPool, availableParallelism } from 'poolifier' | |
4 | import { type WorkerData, type WorkerResponse } from './types.js' | |
5 | ||
6 | const workerFile = join( | |
7 | dirname(fileURLToPath(import.meta.url)), | |
8 | `worker${extname(fileURLToPath(import.meta.url))}` | |
9 | ) | |
10 | ||
b2b02b3d | 11 | export const httpClientPool = new FixedThreadPool<WorkerData, WorkerResponse>( |
11856b30 JB |
12 | availableParallelism(), |
13 | workerFile, | |
14 | { | |
15 | enableTasksQueue: true, | |
b2b02b3d JB |
16 | tasksQueueOptions: { |
17 | concurrency: 8 | |
18 | }, | |
11856b30 JB |
19 | errorHandler: (e: Error) => { |
20 | console.error(e) | |
21 | } | |
22 | } | |
23 | ) |