build(deps-dev): apply updates
[poolifier.git] / src / pools / selection-strategies / round-robin-worker-choice-strategy.ts
index fdf5ac84fddf87235b1d7732e81f2ccff3aae53b..b023234a202cacc50b8f2505859e4e444bcf8f0f 100644 (file)
@@ -50,7 +50,9 @@ export class RoundRobinWorkerChoiceStrategy<
   /** @inheritDoc */
   public choose (): number {
     const chosenWorkerNodeKey = this.nextWorkerNodeKey
-    this.roundRobinNextWorkerNodeKey()
+    do {
+      this.roundRobinNextWorkerNodeKey()
+    } while (!this.isWorkerNodeReady(this.nextWorkerNodeKey))
     return chosenWorkerNodeKey
   }
 
@@ -66,10 +68,11 @@ export class RoundRobinWorkerChoiceStrategy<
     return true
   }
 
-  private roundRobinNextWorkerNodeKey (): void {
+  private roundRobinNextWorkerNodeKey (): number {
     this.nextWorkerNodeKey =
       this.nextWorkerNodeKey === this.pool.workerNodes.length - 1
         ? 0
         : this.nextWorkerNodeKey + 1
+    return this.nextWorkerNodeKey
   }
 }