refactor: use builtin retry mechanism in worker choice strategies
[poolifier.git] / src / pools / selection-strategies / interleaved-weighted-round-robin-worker-choice-strategy.ts
index 15a6c7f48eaac7f0a81e5a30bfd74762a426435d..eee39ec8d646da13324c7050e86afc33882fa22c 100644 (file)
@@ -122,20 +122,18 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy<
   }
 
   private interleavedWeightedRoundRobinNextWorkerNodeId (): void {
-    do {
-      if (
-        this.roundId === this.roundWeights.length - 1 &&
-        this.workerNodeId === this.pool.workerNodes.length - 1
-      ) {
-        this.roundId = 0
-        this.workerNodeId = 0
-      } else if (this.workerNodeId === this.pool.workerNodes.length - 1) {
-        this.roundId = this.roundId + 1
-        this.workerNodeId = 0
-      } else {
-        this.workerNodeId = this.workerNodeId + 1
-      }
-    } while (!this.isWorkerNodeReady(this.workerNodeId))
+    if (
+      this.roundId === this.roundWeights.length - 1 &&
+      this.workerNodeId === this.pool.workerNodes.length - 1
+    ) {
+      this.roundId = 0
+      this.workerNodeId = 0
+    } else if (this.workerNodeId === this.pool.workerNodes.length - 1) {
+      this.roundId = this.roundId + 1
+      this.workerNodeId = 0
+    } else {
+      this.workerNodeId = this.workerNodeId + 1
+    }
   }
 
   /** @inheritDoc */