## [Unreleased]
+### Fixed
+
+- Fix pool readiness semantic.
+
## [2.6.10] - 2023-07-08
### Fixed
private get starting (): boolean {
return (
- !this.full ||
- (this.full && this.workerNodes.some(workerNode => !workerNode.info.ready))
+ this.workerNodes.length < this.minSize ||
+ (this.workerNodes.length >= this.minSize &&
+ this.workerNodes.some(workerNode => !workerNode.info.ready))
)
}
private get ready (): boolean {
return (
- this.full && this.workerNodes.every(workerNode => workerNode.info.ready)
+ this.workerNodes.length >= this.minSize &&
+ this.workerNodes.every(workerNode => workerNode.info.ready)
)
}
* Events that can currently be listened to:
*
* - `'full'`: Emitted when the pool is dynamic and the number of workers created has reached the maximum size expected.
- * - `'ready'`: Emitted when the number of workers created in the pool has reached the maximum size expected and are ready.
+ * - `'ready'`: Emitted when the number of workers created in the pool has reached the minimum size expected and are ready.
* - `'busy'`: Emitted when the number of workers created in the pool has reached the maximum size expected and are executing at least one task.
* - `'error'`: Emitted when an uncaught error occurs.
* - `'taskError'`: Emitted when an error occurs while executing a task.
})
it("Verify that pool event emitter 'ready' event can register a callback", async () => {
- const pool = new FixedClusterPool(
+ const pool = new DynamicClusterPool(
+ Math.floor(numberOfWorkers / 2),
numberOfWorkers,
'./tests/worker-files/cluster/testWorker.js'
)
expect(poolReady).toBe(1)
expect(poolInfo).toStrictEqual({
version,
- type: PoolTypes.fixed,
+ type: PoolTypes.dynamic,
worker: WorkerTypes.cluster,
ready: true,
strategy: WorkerChoiceStrategies.ROUND_ROBIN,