// a fixed worker_threads pool
const pool = new FixedThreadPool(availableParallelism(), './yourWorker.js', {
- errorHandler: e => console.error(e),
- onlineHandler: () => console.info('worker is online')
+ onlineHandler: () => console.info('worker is online'),
+ errorHandler: e => console.error(e)
})
pool.emitter?.on(PoolEvents.ready, () => console.info('Pool is ready'))
// or a dynamic worker_threads pool
const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), './yourWorker.js', {
- errorHandler: e => console.error(e),
- onlineHandler: () => console.info('worker is online')
+ onlineHandler: () => console.info('worker is online'),
+ errorHandler: e => console.error(e)
})
pool.emitter?.on(PoolEvents.full, () => console.info('Pool is full'))
availableParallelism(),
'./yourWorker.js',
{
- errorHandler: e => console.error(e),
- onlineHandler: () => console.info('worker is online')
+ onlineHandler: () => console.info('worker is online'),
+ errorHandler: e => console.error(e)
}
)
let poolFull = 0
} = require('poolifier')
const pool = new FixedThreadPool(availableParallelism(), './yourWorker.cjs', {
- errorHandler: e => console.error(e),
- onlineHandler: () => console.info('worker is online')
+ onlineHandler: () => console.info('worker is online'),
+ errorHandler: e => console.error(e)
})
let poolReady = 0
let poolBusy = 0
availableParallelism(),
'./multiFunctionWorker.cjs',
{
- errorHandler: e => console.error(e),
- onlineHandler: () => console.info('worker is online')
+ onlineHandler: () => console.info('worker is online'),
+ errorHandler: e => console.error(e)
}
)
availableParallelism(),
workerFile,
{
- errorHandler: (e: Error) => {
- console.error(e)
- },
onlineHandler: () => {
console.info('Worker is online')
+ },
+ errorHandler: (e: Error) => {
+ console.error(e)
}
}
)
availableParallelism(),
workerFile,
{
- errorHandler: (e: Error) => {
- console.error(e)
- },
onlineHandler: () => {
console.info('Worker is online')
+ },
+ errorHandler: (e: Error) => {
+ console.error(e)
}
}
)