Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/express-cluster...
[poolifier.git] / benchmarks / internal / cluster-worker.js
index a4742a28d43fafe7fe1e21e2e0b6cfe3932805c8..18bd648c72ce73d454b3503b038719aeade6bd11 100644 (file)
@@ -1,17 +1,15 @@
-'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)