Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/express-hybrid...
[poolifier.git] / benchmarks / internal / cluster-worker.cjs
... / ...
CommitLineData
1const { isPrimary } = require('node:cluster')
2const { ClusterWorker } = require('../../lib/index.cjs')
3const { executeTaskFunction } = require('../benchmarks-utils.cjs')
4const { TaskFunctions } = require('../benchmarks-types.cjs')
5
6const taskFunction = data => {
7 data = data || {}
8 data.function = data.function || TaskFunctions.factorial
9 data.debug = data.debug || false
10 const res = executeTaskFunction(data)
11 data.debug === true && console.debug(`This is the main thread ${isPrimary}`)
12 return res
13}
14
15module.exports = new ClusterWorker(taskFunction)