X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Finterleaved-weighted-round-robin-worker-choice-strategy.ts;h=e37543820593a68b6860e7b597c40919c8866e9d;hb=9fe8fd698590c2494dc6793cfd8c08026fe88a31;hp=4b59a55461e7e92596c5ead2f7fdaca6eabf9d71;hpb=0676e5d32c8f8ee5c5b7f5998f4973b0a276460f;p=poolifier.git diff --git a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts index 4b59a554..e3754382 100644 --- a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts @@ -48,7 +48,7 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< /** @inheritDoc */ public reset (): boolean { - this.nextWorkerNodeKey = 0 + this.resetWorkerNodeKeyProperties() this.roundId = 0 return true } @@ -60,7 +60,7 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< /** @inheritDoc */ public choose (): number | undefined { - let roundId: number = this.roundId + let roundId!: number let workerNodeId: number | undefined for ( let roundIndex = this.roundId; @@ -74,12 +74,12 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< workerNodeKey < this.pool.workerNodes.length; workerNodeKey++ ) { + if (!this.isWorkerNodeEligible(workerNodeKey)) { + continue + } const workerWeight = this.opts.weights?.[workerNodeKey] ?? this.defaultWorkerWeight - if ( - this.isWorkerNodeEligible(workerNodeKey) && - workerWeight >= this.roundWeights[roundIndex] - ) { + if (workerWeight >= this.roundWeights[roundIndex]) { workerNodeId = workerNodeKey break }