refactor: move back pressure event emission in the helper
[poolifier.git] / src / pools / selection-strategies / weighted-round-robin-worker-choice-strategy.ts
index 4921df6dd115899261bd05f6fa2f223f09605e91..b5c566d51b2e8e0d41261c11acc9956674be9b5b 100644 (file)
@@ -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
   }