* @returns The pool utilization.
*/
private get utilization (): number {
- const poolRunTimeCapacity =
+ const poolTimeCapacity =
(performance.now() - this.startTimestamp) * this.maxSize
const totalTasksRunTime = this.workerNodes.reduce(
(accumulator, workerNode) =>
accumulator + (workerNode.usage.waitTime?.aggregate ?? 0),
0
)
- return (totalTasksRunTime + totalTasksWaitTime) / poolRunTimeCapacity
+ return (totalTasksRunTime + totalTasksWaitTime) / poolTimeCapacity
}
/**
?.worker
}
+ /**
+ * Checks if the worker id sent in the received message from a worker is valid.
+ *
+ * @param message - The received message.
+ * @throws {@link https://nodejs.org/api/errors.html#class-error} If the worker id is invalid.
+ */
private checkMessageWorkerId (message: MessageValue<Response>): void {
if (
message.workerId != null &&
if (this.emitter != null) {
this.emitter.emit(PoolEvents.error, error)
}
- if (this.opts.enableTasksQueue === true) {
- this.redistributeQueuedTasks(worker)
- }
if (this.opts.restartWorkerOnError === true && !this.starting) {
if (this.getWorkerInfo(this.getWorkerNodeKey(worker)).dynamic) {
this.createAndSetupDynamicWorker()
this.createAndSetupWorker()
}
}
+ if (this.opts.enableTasksQueue === true) {
+ this.redistributeQueuedTasks(worker)
+ }
})
worker.on('online', this.opts.onlineHandler ?? EMPTY_FUNCTION)
worker.on('exit', this.opts.exitHandler ?? EMPTY_FUNCTION)