refactor: split TestUtils class into arrow functions
[poolifier.git] / tests / worker-files / cluster / testWorker.js
CommitLineData
325f50bc 1'use strict'
1641b313 2const { isMaster } = require('cluster')
65d7a1c9 3const { ClusterWorker, KillBehaviors } = require('../../../lib')
bac873bd 4const { executeWorkerFunction } = require('../../test-utils')
2d2e32c2 5const { WorkerFunctions } = require('../../test-types')
325f50bc
S
6
7function test (data) {
6db75ad9
JB
8 data = data || {}
9 data.function = data.function || WorkerFunctions.jsonIntegerSerialization
bac873bd 10 const result = executeWorkerFunction(data)
70a4f5ea
JB
11 if (result == null) {
12 return isMaster
13 }
14 return result
325f50bc
S
15}
16
4c35177b 17module.exports = new ClusterWorker(test, {
18 maxInactiveTime: 500,
1a81f8af 19 killBehavior: KillBehaviors.HARD
4c35177b 20})