refactor: forEach -> for ... of on collections
[poolifier.git] / src / pools / selection-strategies / weighted-round-robin-worker-choice-strategy.ts
index 1817394933978fcc9a18a4052dcec1c44efe5201..bda206a7d7e1521ac8a6056b0485ad18e7698375 100644 (file)
@@ -50,7 +50,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
     opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
   ) {
     super(pool, opts)
-    this.checkOptions(this.opts)
+    this.setRequiredStatistics(this.opts)
     this.defaultWorkerWeight = this.computeDefaultWorkerWeight()
   }
 
@@ -91,11 +91,8 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
     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.workerVirtualTaskRunTime = 0
     }