+
+ private weightedRoundRobinNextWorkerNodeKey (): number | undefined {
+ const workerWeight =
+ this.opts.weights?.[
+ this.nextWorkerNodeKey ?? this.previousWorkerNodeKey
+ ] ?? this.defaultWorkerWeight
+ if (this.workerNodeVirtualTaskRunTime < workerWeight) {
+ this.workerNodeVirtualTaskRunTime =
+ this.workerNodeVirtualTaskRunTime +
+ this.getWorkerNodeTaskRunTime(
+ this.nextWorkerNodeKey ?? this.previousWorkerNodeKey
+ )
+ } else {
+ this.nextWorkerNodeKey =
+ this.nextWorkerNodeKey === this.pool.workerNodes.length - 1
+ ? 0
+ : (this.nextWorkerNodeKey ?? this.previousWorkerNodeKey) + 1
+ this.workerNodeVirtualTaskRunTime = 0
+ }
+ return this.nextWorkerNodeKey
+ }