refactor: split TestUtils class into arrow 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 { executeWorkerFunction } = 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 = 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 })