refactor: cleanup eslint configuration
[poolifier.git] / examples / typescript / smtp-client-pool / src / pool.ts
CommitLineData
9aef1431 1import { dirname, extname, join } from 'node:path'
ded253e2
JB
2import { fileURLToPath } from 'node:url'
3
f8374594 4import type SMTPTransport from 'nodemailer/lib/smtp-transport/index.js'
ded253e2
JB
5import { availableParallelism, DynamicThreadPool } from 'poolifier'
6
ef083f7b 7import type { WorkerData } from './types.js'
9aef1431
JB
8
9const workerFile = join(
10 dirname(fileURLToPath(import.meta.url)),
11 `worker${extname(fileURLToPath(import.meta.url))}`
12)
13
f8374594
JB
14export const smtpClientPool = new DynamicThreadPool<
15WorkerData,
16SMTPTransport.SentMessageInfo
0fce423d 17>(0, availableParallelism(), workerFile, {
f8374594
JB
18 enableTasksQueue: true,
19 tasksQueueOptions: {
20 concurrency: 8
21 },
22 errorHandler: (e: Error) => {
23 console.error('Thread worker error:', e)
9aef1431 24 }
f8374594 25})