40d614c7364fe17feaa41bec8c3742842f450832
[poolifier.git] / benchmarks / internal / cluster-worker.cjs
1 const { isPrimary } = require('node:cluster')
2 const { ClusterWorker } = require('../../lib/index.cjs')
3 const { executeTaskFunction } = require('../benchmarks-utils.cjs')
4 const { TaskFunctions } = require('../benchmarks-types.cjs')
5
6 const taskFunction = data => {
7 data = data || {}
8 data.function = data.function || TaskFunctions.factorial
9 data.debug = data.debug || false
10 const res = executeTaskFunction(data)
11 // eslint-disable-next-line @typescript-eslint/no-unused-expressions
12 data.debug === true && console.debug(`This is the main thread ${isPrimary}`)
13 return res
14 }
15
16 module.exports = new ClusterWorker(taskFunction)