Merge pull request #747 from poolifier/multiple-functions
[poolifier.git] / tests / worker-files / cluster / testWorker.js
1 'use strict'
2 const { isMaster } = require('cluster')
3 const { ClusterWorker, KillBehaviors } = require('../../../lib')
4 const TestUtils = require('../../test-utils')
5 const { WorkerFunctions } = require('../../test-types')
6
7 function test (data) {
8 data = data || {}
9 data.function = data.function || WorkerFunctions.jsonIntegerSerialization
10 const result = TestUtils.executeWorkerFunction(data)
11 if (result == null) {
12 return isMaster
13 }
14 return result
15 }
16
17 module.exports = new ClusterWorker(test, {
18 maxInactiveTime: 500,
19 killBehavior: KillBehaviors.HARD
20 })