X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fround-robin-worker-choice-strategy.ts;h=b023234a202cacc50b8f2505859e4e444bcf8f0f;hb=2826fc7a3ba7197b08fe5c352d8965b234f3abc5;hp=fdf5ac84fddf87235b1d7732e81f2ccff3aae53b;hpb=9b1068374b1a52479b07e1e22b692289d5579237;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 fdf5ac84..b023234a 100644 --- a/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts @@ -50,7 +50,9 @@ export class RoundRobinWorkerChoiceStrategy< /** @inheritDoc */ public choose (): number { const chosenWorkerNodeKey = this.nextWorkerNodeKey - this.roundRobinNextWorkerNodeKey() + do { + this.roundRobinNextWorkerNodeKey() + } while (!this.isWorkerNodeReady(this.nextWorkerNodeKey)) return chosenWorkerNodeKey } @@ -66,10 +68,11 @@ export class RoundRobinWorkerChoiceStrategy< return true } - private roundRobinNextWorkerNodeKey (): void { + private roundRobinNextWorkerNodeKey (): number { this.nextWorkerNodeKey = this.nextWorkerNodeKey === this.pool.workerNodes.length - 1 ? 0 : this.nextWorkerNodeKey + 1 + return this.nextWorkerNodeKey } }