fix: calculate round weights in IWRR at setting worker choice strategy
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 7 May 2023 17:05:34 +0000 (19:05 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 7 May 2023 17:05:34 +0000 (19:05 +0200)
options

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts

index 09598355690bd0c65805fa3fdac03ab56bbba495..44d4689fc68e2bd34042132d32951ac420f9e706 100644 (file)
@@ -42,7 +42,7 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy<
   /**
    * Round weights.
    */
-  private readonly roundWeights: number[]
+  private roundWeights: number[]
   /**
    * Default worker weight.
    */
@@ -132,6 +132,12 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy<
     return true
   }
 
+  /** @inheritDoc */
+  public setOptions (opts: WorkerChoiceStrategyOptions): void {
+    super.setOptions(opts)
+    this.roundWeights = this.getRoundWeights()
+  }
+
   private computeDefaultWorkerWeight (): number {
     let cpusCycleTimeWeight = 0
     for (const cpu of cpus()) {