fix: put back properties init in constructor
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 20 Dec 2023 14:30:39 +0000 (15:30 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 20 Dec 2023 14:30:39 +0000 (15:30 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/selection-strategies/abstract-worker-choice-strategy.ts
src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts
tests/pools/abstract-pool.test.mjs

index 91733b52c96cf1f7eff70142146965290772a3aa..fe8c7543551b97b09a162136490357e9a90b0083 100644 (file)
@@ -57,7 +57,12 @@ export abstract class AbstractWorkerChoiceStrategy<
     protected readonly pool: IPool<Worker, Data, Response>,
     protected opts: InternalWorkerChoiceStrategyOptions
   ) {
-    this.setOptions(this.opts)
+    // this.setOptions(this.opts)
+    this.opts = buildInternalWorkerChoiceStrategyOptions(
+      this.pool.info.maxSize,
+      this.opts
+    )
+    this.setTaskStatisticsRequirements(this.opts)
     this.choose = this.choose.bind(this)
   }
 
index 0f718e9817159bd6aedb5012e3246786d4696f50..fe6bbb735cfdf16a1ad2019784c37c0fe648490c 100644 (file)
@@ -56,7 +56,9 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy<
     opts: InternalWorkerChoiceStrategyOptions
   ) {
     super(pool, opts)
-    this.setOptions(this.opts)
+    // this.setOptions(this.opts)
+    this.setTaskStatisticsRequirements(this.opts)
+    this.roundWeights = this.getRoundWeights()
   }
 
   /** @inheritDoc */
index 6bb6e1a613cc437a1f0cbc1bf2a781fe0da21fe6..12e1a530b3643c750298ddd14fd2f54376504f9f 100644 (file)
@@ -249,11 +249,11 @@ describe('Abstract pool test suite', () => {
             Object.keys(workerChoiceStrategy.opts.weights).length,
           runTime: { median: false },
           waitTime: { median: false },
-          elu: { median: false }
-          // weights: expect.objectContaining({
-          //   0: expect.any(Number),
-          //   [pool.info.maxSize - 1]: expect.any(Number)
-          // })
+          elu: { median: false },
+          weights: expect.objectContaining({
+            0: expect.any(Number),
+            [pool.info.maxSize - 1]: expect.any(Number)
+          })
         })
       )
     }
@@ -494,10 +494,6 @@ describe('Abstract pool test suite', () => {
           runTime: { median: false },
           waitTime: { median: false },
           elu: { median: false }
-          // weights: expect.objectContaining({
-          //   0: expect.any(Number),
-          //   [pool.info.maxSize - 1]: expect.any(Number)
-          // })
         })
       )
     }
@@ -550,10 +546,6 @@ describe('Abstract pool test suite', () => {
           runTime: { median: true },
           waitTime: { median: false },
           elu: { median: true }
-          // weights: expect.objectContaining({
-          //   0: expect.any(Number),
-          //   [pool.info.maxSize - 1]: expect.any(Number)
-          // })
         })
       )
     }
@@ -606,10 +598,6 @@ describe('Abstract pool test suite', () => {
           runTime: { median: false },
           waitTime: { median: false },
           elu: { median: false }
-          // weights: expect.objectContaining({
-          //   0: expect.any(Number),
-          //   [pool.info.maxSize - 1]: expect.any(Number)
-          // })
         })
       )
     }