/** @inheritDoc */
public choose (): number {
const chosenWorkerNodeKey = this.nextWorkerNodeKey
- this.weightedRoundRobinNextWorkerNodeKey()
+ do {
+ this.weightedRoundRobinNextWorkerNodeKey()
+ } while (!this.isWorkerNodeReady(this.nextWorkerNodeKey))
return chosenWorkerNodeKey
}
return true
}
- private weightedRoundRobinNextWorkerNodeKey (): void {
+ private weightedRoundRobinNextWorkerNodeKey (): number {
const workerVirtualTaskRunTime = this.workerVirtualTaskRunTime
const workerWeight =
this.opts.weights?.[this.nextWorkerNodeKey] ?? this.defaultWorkerWeight
: this.nextWorkerNodeKey + 1
this.workerVirtualTaskRunTime = 0
}
+ return this.nextWorkerNodeKey
}
}