return []
}
+ private shallExecuteTask (workerNodeKey: number): boolean {
+ return (
+ this.tasksQueueSize(workerNodeKey) === 0 &&
+ this.workerNodes[workerNodeKey].usage.tasks.executing <
+ (this.opts.tasksQueueOptions?.concurrency as number)
+ )
+ }
+
/** @inheritDoc */
public async execute (
data?: Data,
if (
this.opts.enableTasksQueue === false ||
(this.opts.enableTasksQueue === true &&
- this.tasksQueueSize(workerNodeKey) === 0 &&
- this.workerNodes[workerNodeKey].usage.tasks.executing <
- (this.opts.tasksQueueOptions?.concurrency as number))
+ this.shallExecuteTask(workerNodeKey))
) {
this.executeTask(workerNodeKey, task)
} else {
...(this.dequeueTask(workerNodeKey) as Task<Data>),
workerId: destinationWorkerNode.info.id as number
}
- if (
- this.tasksQueueSize(destinationWorkerNodeKey) === 0 &&
- destinationWorkerNode.usage.tasks.executing <
- (this.opts.tasksQueueOptions?.concurrency as number)
- ) {
+ if (this.shallExecuteTask(destinationWorkerNodeKey)) {
this.executeTask(destinationWorkerNodeKey, task)
} else {
this.enqueueTask(destinationWorkerNodeKey, task)
...(sourceWorkerNode.popTask() as Task<Data>),
workerId: destinationWorkerNode.info.id as number
}
- if (
- this.tasksQueueSize(destinationWorkerNodeKey) === 0 &&
- destinationWorkerNode.usage.tasks.executing <
- (this.opts.tasksQueueOptions?.concurrency as number)
- ) {
+ if (this.shallExecuteTask(destinationWorkerNodeKey)) {
this.executeTask(destinationWorkerNodeKey, task)
} else {
this.enqueueTask(destinationWorkerNodeKey, task)
...(sourceWorkerNode.popTask() as Task<Data>),
workerId: workerNode.info.id as number
}
- if (
- this.tasksQueueSize(workerNodeKey) === 0 &&
- workerNode.usage.tasks.executing <
- (this.opts.tasksQueueOptions?.concurrency as number)
- ) {
+ if (this.shallExecuteTask(workerNodeKey)) {
this.executeTask(workerNodeKey, task)
} else {
this.enqueueTask(workerNodeKey, task)