refactor: factor out inputs type check
[poolifier.git] / src / pools / selection-strategies / weighted-round-robin-worker-choice-strategy.ts
index b0750949749de7f2d22ec0c97733b2f3ea5ec8b9..ad20db423826aa46a649da5512a3358e9f119572 100644 (file)
@@ -64,12 +64,12 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
   /** @inheritDoc */
   public choose (): number {
     const chosenWorkerNodeKey = this.currentWorkerNodeId
-    const workerTaskRunTime = this.workerVirtualTaskRunTime ?? 0
+    const workerVirtualTaskRunTime = this.workerVirtualTaskRunTime ?? 0
     const workerTaskWeight =
       this.opts.weights?.[chosenWorkerNodeKey] ?? this.defaultWorkerWeight
-    if (workerTaskRunTime < workerTaskWeight) {
+    if (workerVirtualTaskRunTime < workerTaskWeight) {
       this.workerVirtualTaskRunTime =
-        workerTaskRunTime +
+        workerVirtualTaskRunTime +
         (this.getWorkerVirtualTaskRunTime(chosenWorkerNodeKey) ?? 0)
     } else {
       this.currentWorkerNodeId =