-'use strict'
-const { isMaster } = require('cluster')
+const { isPrimary } = require('node:cluster')
const { ClusterWorker } = require('../../lib')
-const { executeWorkerFunction } = require('../benchmarks-utils')
-const { WorkerFunctions } = require('../benchmarks-types')
+const { executeTaskFunction } = require('../benchmarks-utils.js')
+const { TaskFunctions } = require('../benchmarks-types.js')
-const debug = false
-
-function yourFunction (data) {
+const taskFunction = data => {
data = data || {}
- data.function = data.function || WorkerFunctions.jsonIntegerSerialization
- executeWorkerFunction(data)
- debug === true && console.debug('This is the main thread ' + isMaster)
- return { ok: 1 }
+ data.function = data.function || TaskFunctions.jsonIntegerSerialization
+ data.debug = data.debug || false
+ const res = executeTaskFunction(data)
+ data.debug === true && console.debug(`This is the main thread ${isPrimary}`)
+ return res
}
-module.exports = new ClusterWorker(yourFunction)
+module.exports = new ClusterWorker(taskFunction)