/** @inheritDoc */
public choose (): number {
const chosenWorkerNodeKey = this.nextWorkerNodeKey
- this.roundRobinNextWorkerNodeKey()
+ do {
+ this.roundRobinNextWorkerNodeKey()
+ } while (!this.isWorkerNodeReady(this.nextWorkerNodeKey))
return chosenWorkerNodeKey
}
return true
}
- private roundRobinNextWorkerNodeKey (): void {
+ private roundRobinNextWorkerNodeKey (): number {
this.nextWorkerNodeKey =
this.nextWorkerNodeKey === this.pool.workerNodes.length - 1
? 0
: this.nextWorkerNodeKey + 1
+ return this.nextWorkerNodeKey
}
}