Merge dependabot/npm_and_yarn/examples/typescript/websocket-server-pool/ws-worker_thr...
[poolifier.git] / benchmarks / internal / cluster-worker.js
CommitLineData
ab7bb4f8
JB
1const { isPrimary } = require('node:cluster')
2const { ClusterWorker } = require('../../lib')
3const { executeTaskFunction } = require('../benchmarks-utils.js')
4const { TaskFunctions } = require('../benchmarks-types.js')
57df5469 5
041dc05b 6const taskFunction = data => {
2d2e32c2 7 data = data || {}
dbca3be9 8 data.function = data.function || TaskFunctions.jsonIntegerSerialization
f1c674cd 9 data.debug = data.debug || false
dbca3be9 10 const res = executeTaskFunction(data)
f1c674cd 11 data.debug === true && console.debug(`This is the main thread ${isPrimary}`)
30b963d4 12 return res
106744f7 13}
14
ab7bb4f8 15module.exports = new ClusterWorker(taskFunction)