Merge dependabot/npm_and_yarn/examples/typescript/websocket-server-pool/ws-worker_thr...
[poolifier.git] / benchmarks / internal / cluster-worker.js
1 const { isPrimary } = require('node:cluster')
2 const { ClusterWorker } = require('../../lib')
3 const { executeTaskFunction } = require('../benchmarks-utils.js')
4 const { TaskFunctions } = require('../benchmarks-types.js')
5
6 const taskFunction = data => {
7 data = data || {}
8 data.function = data.function || TaskFunctions.jsonIntegerSerialization
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
15 module.exports = new ClusterWorker(taskFunction)