X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fweighted-round-robin-worker-choice-strategy.ts;h=b5c566d51b2e8e0d41261c11acc9956674be9b5b;hb=cb9b167557f9a903021bca1c7aba9fc9b24ae1b1;hp=ed38aa1497176ba88751e83a850e1794b3aaa9fd;hpb=9b1068374b1a52479b07e1e22b692289d5579237;p=poolifier.git diff --git a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts index ed38aa14..b5c566d5 100644 --- a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts @@ -77,7 +77,9 @@ export class WeightedRoundRobinWorkerChoiceStrategy< /** @inheritDoc */ public choose (): number { const chosenWorkerNodeKey = this.nextWorkerNodeKey - this.weightedRoundRobinNextWorkerNodeKey() + do { + this.weightedRoundRobinNextWorkerNodeKey() + } while (!this.isWorkerNodeEligible(this.nextWorkerNodeKey)) return chosenWorkerNodeKey } @@ -94,7 +96,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy< return true } - private weightedRoundRobinNextWorkerNodeKey (): void { + private weightedRoundRobinNextWorkerNodeKey (): number { const workerVirtualTaskRunTime = this.workerVirtualTaskRunTime const workerWeight = this.opts.weights?.[this.nextWorkerNodeKey] ?? this.defaultWorkerWeight @@ -109,5 +111,6 @@ export class WeightedRoundRobinWorkerChoiceStrategy< : this.nextWorkerNodeKey + 1 this.workerVirtualTaskRunTime = 0 } + return this.nextWorkerNodeKey } }