this.removeWorkerNode(worker)
})
- this.pushWorkerNode(worker)
+ this.addWorkerNode(worker)
this.afterWorkerSetup(worker)
}
})
const workerInfo = this.getWorkerInfo(this.getWorkerNodeKey(worker))
+ workerInfo.dynamic = true
if (this.workerChoiceStrategyContext.getStrategyPolicy().useDynamicWorker) {
workerInfo.ready = true
}
- workerInfo.dynamic = true
this.sendToWorker(worker, {
- checkAlive: true,
+ checkActive: true,
workerId: workerInfo.id as number
})
return worker
return message => {
this.checkMessageWorkerId(message)
if (message.ready != null) {
- // Worker ready message received
- this.handleWorkerReadyMessage(message)
+ // Worker ready response received
+ this.handleWorkerReadyResponse(message)
} else if (message.id != null) {
// Task execution response received
this.handleTaskExecutionResponse(message)
}
}
- private handleWorkerReadyMessage (message: MessageValue<Response>): void {
+ private handleWorkerReadyResponse (message: MessageValue<Response>): void {
const worker = this.getWorkerById(message.workerId)
this.getWorkerInfo(this.getWorkerNodeKey(worker as Worker)).ready =
message.ready as boolean
}
/**
- * Pushes the given worker in the pool worker nodes.
+ * Adds the given worker in the pool worker nodes.
*
* @param worker - The worker.
* @returns The worker nodes length.
*/
- private pushWorkerNode (worker: Worker): number {
+ private addWorkerNode (worker: Worker): number {
const workerNode = new WorkerNode<Worker, Data>(worker, this.worker)
// Flag the worker node as ready at pool startup.
if (this.starting) {
}
}
+ /**
+ * Executes the given task on the given worker.
+ *
+ * @param worker - The worker.
+ * @param task - The task to execute.
+ */
private executeTask (workerNodeKey: number, task: Task<Data>): void {
this.beforeTaskExecutionHook(workerNodeKey, task)
this.sendToWorker(this.workerNodes[workerNodeKey].worker, task)