- this.workerNodes.push({
- worker,
- info: this.getInitialWorkerInfo(worker),
- usage: this.getInitialWorkerUsage(),
- tasksQueue: new Queue<Task<Data>>()
- })
- this.setWorkerNodeTasksUsage(
- this.workerNodes[this.getWorkerNodeKey(worker)],
- this.getInitialWorkerUsage(worker)
- )
- return this.workerNodes.length
- }
-
- /**
- * Gets the worker id.
- *
- * @param worker - The worker.
- * @returns The worker id.
- */
- private getWorkerId (worker: Worker): number | undefined {
- if (this.worker === WorkerTypes.thread) {
- return worker.threadId
- } else if (this.worker === WorkerTypes.cluster) {
- return worker.id
- }