waitTime: { median: false },
elu: { median: false }
})
+ for (const [, workerChoiceStrategy] of pool.workerChoiceStrategyContext
+ .workerChoiceStrategies) {
+ expect(workerChoiceStrategy.opts).toStrictEqual({
+ retries: 6,
+ runTime: { median: false },
+ waitTime: { median: false },
+ elu: { median: false }
+ })
+ }
expect(pool.opts.messageHandler).toBeUndefined()
expect(pool.opts.errorHandler).toBeUndefined()
expect(pool.opts.onlineHandler).toBeUndefined()
elu: { median: false },
weights: { 0: 300, 1: 200 }
})
+ for (const [, workerChoiceStrategy] of pool.workerChoiceStrategyContext
+ .workerChoiceStrategies) {
+ expect(workerChoiceStrategy.opts).toStrictEqual({
+ retries: 6,
+ runTime: { median: true },
+ waitTime: { median: false },
+ elu: { median: false },
+ weights: { 0: 300, 1: 200 }
+ })
+ }
expect(pool.opts.messageHandler).toStrictEqual(testHandler)
expect(pool.opts.errorHandler).toStrictEqual(testHandler)
expect(pool.opts.onlineHandler).toStrictEqual(testHandler)
const { expect } = require('expect')
const {
+ DynamicClusterPool,
DynamicThreadPool,
FixedClusterPool,
FixedThreadPool,
expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
workerChoiceStrategy
)
+ expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
+ retries: 6,
+ runTime: { median: false },
+ waitTime: { median: false },
+ elu: { median: false }
+ })
+ expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({
+ retries: 6,
+ runTime: { median: false },
+ waitTime: { median: false },
+ elu: { median: false }
+ })
+ await pool.destroy()
+ }
+ for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
+ const pool = new DynamicClusterPool(
+ min,
+ max,
+ './tests/worker-files/cluster/testWorker.js'
+ )
+ pool.setWorkerChoiceStrategy(workerChoiceStrategy, { retries: 3 })
+ expect(pool.opts.workerChoiceStrategy).toBe(workerChoiceStrategy)
+ expect(pool.workerChoiceStrategyContext.workerChoiceStrategy).toBe(
+ workerChoiceStrategy
+ )
+ expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
+ retries: 3,
+ runTime: { median: false },
+ waitTime: { median: false },
+ elu: { median: false }
+ })
+ expect(pool.workerChoiceStrategyContext.opts).toStrictEqual({
+ retries: 3,
+ runTime: { median: false },
+ waitTime: { median: false },
+ elu: { median: false }
+ })
await pool.destroy()
}
})