X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fround-robin-worker-choice-strategy.ts;h=7c49cec75689a8ca64aa101b51ec8f86890f1409;hb=3c8a79b4b146fb20de682c19d8b409bfbdf05df4;hp=19dd3872c116723756fb146a4a57506b10523ab0;hpb=ae3ab61d14adc1f0511e8dea1f69a1d44e7effdf;p=poolifier.git diff --git a/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts index 19dd3872..7c49cec7 100644 --- a/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts @@ -46,6 +46,7 @@ export class RoundRobinWorkerChoiceStrategy< const chosenWorkerNodeKey = this.nextWorkerNodeKey this.setPreviousWorkerNodeKey(chosenWorkerNodeKey) this.roundRobinNextWorkerNodeKey() + this.checkNextWorkerNodeReadiness() return chosenWorkerNodeKey } @@ -70,12 +71,10 @@ export class RoundRobinWorkerChoiceStrategy< } private roundRobinNextWorkerNodeKey (): number | undefined { - do { - this.nextWorkerNodeKey = - this.nextWorkerNodeKey === this.pool.workerNodes.length - 1 - ? 0 - : (this.nextWorkerNodeKey ?? this.previousWorkerNodeKey) + 1 - } while (!this.isWorkerNodeReady(this.nextWorkerNodeKey)) + this.nextWorkerNodeKey = + this.nextWorkerNodeKey === this.pool.workerNodes.length - 1 + ? 0 + : (this.nextWorkerNodeKey ?? this.previousWorkerNodeKey) + 1 return this.nextWorkerNodeKey } }