From: Jérôme Benoit Date: Wed, 20 Dec 2023 14:30:39 +0000 (+0100) Subject: fix: put back properties init in constructor X-Git-Tag: v3.1.7~1^2~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3d6f0f7377c842be430708f7fe2b2d8a33d57e3d;p=poolifier.git fix: put back properties init in constructor Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index 91733b52..fe8c7543 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -57,7 +57,12 @@ export abstract class AbstractWorkerChoiceStrategy< protected readonly pool: IPool, 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) } diff --git a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts index 0f718e98..fe6bbb73 100644 --- a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts @@ -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 */ diff --git a/tests/pools/abstract-pool.test.mjs b/tests/pools/abstract-pool.test.mjs index 6bb6e1a6..12e1a530 100644 --- a/tests/pools/abstract-pool.test.mjs +++ b/tests/pools/abstract-pool.test.mjs @@ -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) - // }) }) ) }