private hasBackPressure (): boolean {
return (
this.opts.enableTasksQueue === true &&
- this.workerNodes.findIndex(
- workerNode => !workerNode.hasBackPressure()
- ) === -1
+ this.workerNodes.reduce(
+ (accumulator, workerNode) =>
+ workerNode.info.backPressure ? accumulator + 1 : accumulator,
+ 0
+ ) === this.workerNodes.length
)
}
}
}
+ /**
+ * Whether the worker node has back pressure (i.e. its tasks queue is full).
+ * @returns `true` if the worker node has back pressure, `false` otherwise.
+ */
+ private hasBackPressure (): boolean {
+ return this.tasksQueue.size >= this.tasksQueueBackPressureSize
+ }
+
private initTaskFunctionWorkerUsage (name: string): WorkerUsage {
const getTaskFunctionQueueSize = (): number => {
let taskFunctionQueueSize = 0
return this.taskFunctionsUsage.get(name)
}
- /** @inheritdoc */
- public hasBackPressure (): boolean {
- return this.tasksQueue.size >= this.tasksQueueBackPressureSize
- }
-
/** @inheritdoc */
public registerOnceWorkerEventHandler (
event: string,
* @returns The task function worker usage statistics if the task function worker usage statistics are initialized, `undefined` otherwise.
*/
readonly getTaskFunctionWorkerUsage: (name: string) => undefined | WorkerUsage
- /**
- * Whether the worker node has back pressure (i.e. its tasks queue is full).
- * @returns `true` if the worker node has back pressure, `false` otherwise.
- */
- readonly hasBackPressure: () => boolean
/**
* Worker info.
*/