WRR: Fix worker choice initial runtime value on each round
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 14 Oct 2022 22:56:10 +0000 (00:56 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 14 Oct 2022 22:56:10 +0000 (00:56 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts

index aa751e5437b640ca999ab17c684fc9f32a95882d..4b1e5382af333d2edb59eb5ae41d1c5132f6ccb3 100644 (file)
@@ -91,7 +91,11 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
         this.currentWorkerIndex === this.pool.workers.length - 1
           ? 0
           : this.currentWorkerIndex + 1
-      this.setWorkerTaskRunTime(chosenWorker, workerTaskWeight, 0)
+      this.setWorkerTaskRunTime(
+        this.pool.workers[this.currentWorkerIndex],
+        workerTaskWeight,
+        0
+      )
     }
     return chosenWorker
   }