X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fweighted-round-robin-worker-choice-strategy.ts;h=fecba414ae1f8b18c29f566192ba577eb60b2288;hb=c62a9bbc12416e26acbb3b86b5090d6186b14b60;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..fecba414 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.isWorkerNodeReady(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 } }