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=36ed976c290ce30ad1e027f6f93e76652e530737;hp=19dd3872c116723756fb146a4a57506b10523ab0;hpb=1ed7fb6c99f2fcb5f319d9c1fa2aefc5434f82e4;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 } }