From: Jérôme Benoit Date: Sun, 7 May 2023 20:49:55 +0000 (+0200) Subject: fix: fix round handling at worker removal in IWRR X-Git-Tag: v2.5.0~3^2~42 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=cac70359b46b8437dd8d23ef6176c6cdfd187c0c;p=poolifier.git fix: fix round handling at worker removal in IWRR Signed-off-by: Jérôme Benoit --- 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 89576e338..24f7ac9a4 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 @@ -114,11 +114,12 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< if (this.currentWorkerNodeId === workerNodeKey) { if (this.pool.workerNodes.length === 0) { this.currentWorkerNodeId = 0 - } else { - this.currentWorkerNodeId = - this.currentWorkerNodeId > this.pool.workerNodes.length - 1 - ? this.pool.workerNodes.length - 1 - : this.currentWorkerNodeId + } else if (this.currentWorkerNodeId > this.pool.workerNodes.length - 1) { + this.currentWorkerNodeId = this.pool.workerNodes.length - 1 + this.currentRoundId = + this.currentRoundId === this.roundWeights.length - 1 + ? 0 + : this.currentRoundId + 1 } } return true