### Changed
-- Make orthogonal worker choice strategies tasks distribution and dynamic worker creation usage.
+- Make orthogonal worker choice strategies tasks distribution and created dynamic worker usage.
- Remove the experimental status of the `LEAST_ELU` worker choice strategy.
## [2.6.30] - 2023-08-19
protected checkDynamicPoolSize (min: number, max: number): void {
if (this.type === PoolTypes.dynamic) {
if (max == null) {
- throw new Error(
+ throw new TypeError(
'Cannot instantiate a dynamic pool without specifying the maximum pool size'
)
} else if (!Number.isSafeInteger(max)) {
tasksQueueOptions?.concurrency != null &&
tasksQueueOptions.concurrency <= 0
) {
- throw new Error(
+ throw new RangeError(
`Invalid worker tasks concurrency: ${tasksQueueOptions.concurrency} is a negative integer or zero`
)
}
this.choiceRetriesCount++
return this.execute()
} else if (workerNodeKey == null) {
- throw new TypeError(
+ throw new Error(
`Worker node key chosen is null or undefined after ${this.choiceRetriesCount} retries`
)
}
*/
constructor (worker: Worker, workerType: WorkerType, poolMaxSize: number) {
if (worker == null) {
- throw new Error('Cannot construct a worker node without a worker')
+ throw new TypeError('Cannot construct a worker node without a worker')
}
if (workerType == null) {
- throw new Error('Cannot construct a worker node without a worker type')
+ throw new TypeError(
+ 'Cannot construct a worker node without a worker type'
+ )
}
if (poolMaxSize == null) {
- throw new Error(
+ throw new TypeError(
'Cannot construct a worker node without a pool maximum size'
)
}
if (isNaN(poolMaxSize)) {
- throw new Error(
+ throw new TypeError(
'Cannot construct a worker node with a NaN pool maximum size'
)
}
}
)
).toThrowError(
- 'Cannot start a pool from a worker with the same type as the pool'
+ new Error(
+ 'Cannot start a pool from a worker with the same type as the pool'
+ )
)
})
it('Verify that numberOfWorkers is checked', () => {
expect(() => new FixedThreadPool()).toThrowError(
- 'Cannot instantiate a pool without specifying the number of workers'
+ new Error(
+ 'Cannot instantiate a pool without specifying the number of workers'
+ )
)
})
}
)
).toThrowError(
- new TypeError(
+ new RangeError(
'Invalid worker tasks concurrency: 0 is a negative integer or zero'
)
)
new TypeError('Invalid tasks queue options: must be a plain object')
)
expect(() => pool.setTasksQueueOptions({ concurrency: 0 })).toThrowError(
- new Error(
+ new RangeError(
'Invalid worker tasks concurrency: 0 is a negative integer or zero'
)
)
expect(() => pool.setTasksQueueOptions({ concurrency: -1 })).toThrowError(
- new Error(
+ new RangeError(
'Invalid worker tasks concurrency: -1 is a negative integer or zero'
)
)
WorkerChoiceStrategyUndefinedStub
)
expect(() => workerChoiceStrategyContext.execute()).toThrowError(
- new TypeError(
- 'Worker node key chosen is null or undefined after 6 retries'
- )
+ new Error('Worker node key chosen is null or undefined after 6 retries')
)
workerChoiceStrategyContext.workerChoiceStrategies.set(
workerChoiceStrategyContext.workerChoiceStrategy,
WorkerChoiceStrategyNullStub
)
expect(() => workerChoiceStrategyContext.execute()).toThrowError(
- new TypeError(
- 'Worker node key chosen is null or undefined after 6 retries'
- )
+ new Error('Worker node key chosen is null or undefined after 6 retries')
)
})