build(deps-dev): apply updates
[poolifier.git] / src / pools / selection-strategies / less-busy-worker-choice-strategy.ts
index 10fc3bf761f4908d8b1dd402f2ee2161310665f7..f518f9b17f311ad3a8ad262e3b7e5f0be15cc61b 100644 (file)
@@ -35,7 +35,7 @@ export class LessBusyWorkerChoiceStrategy<
     opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
   ) {
     super(pool, opts)
-    this.checkOptions(this.opts)
+    this.setRequiredStatistics(this.opts)
   }
 
   /** @inheritDoc */
@@ -43,6 +43,11 @@ export class LessBusyWorkerChoiceStrategy<
     return true
   }
 
+  /** @inheritDoc */
+  public update (): boolean {
+    return true
+  }
+
   /** @inheritDoc */
   public choose (): number {
     const freeWorkerNodeKey = this.findFreeWorkerNodeKey()
@@ -51,20 +56,20 @@ export class LessBusyWorkerChoiceStrategy<
     }
     let minRunTime = Infinity
     let lessBusyWorkerNodeKey!: number
-    for (const [index, workerNode] of this.pool.workerNodes.entries()) {
+    for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
       const workerRunTime = workerNode.tasksUsage.runTime
       if (workerRunTime === 0) {
-        return index
+        return workerNodeKey
       } else if (workerRunTime < minRunTime) {
         minRunTime = workerRunTime
-        lessBusyWorkerNodeKey = index
+        lessBusyWorkerNodeKey = workerNodeKey
       }
     }
     return lessBusyWorkerNodeKey
   }
 
   /** @inheritDoc */
-  public remove (workerNodeKey: number): boolean {
+  public remove (): boolean {
     return true
   }
 }