| 1 | 'use strict' |
| 2 | const { isMaster } = require('cluster') |
| 3 | const { ClusterWorker } = require('../../../lib/index') |
| 4 | const { WorkerFunctions, executeWorkerFunction } = require('../benchmark-utils') |
| 5 | |
| 6 | const debug = false |
| 7 | |
| 8 | function yourFunction (data) { |
| 9 | data = data || {} |
| 10 | data.function = data.function || WorkerFunctions.jsonIntegerSerialization |
| 11 | executeWorkerFunction(data) |
| 12 | debug === true && console.debug('This is the main thread ' + isMaster) |
| 13 | return { ok: 1 } |
| 14 | } |
| 15 | |
| 16 | module.exports = new ClusterWorker(yourFunction) |