X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fworker-choice-strategy-context.ts;h=9a015347bc2a430172855116224da8cfc89f2800;hb=bcc9e518ccacb739018c92de22011fa4e8d47ece;hp=6f15daa0645174b4ce55008dbd46057a40f9c927;hpb=d62fc5e18631cc99b49c6792c00dc36fa70339e0;p=poolifier.git diff --git a/src/pools/selection-strategies/worker-choice-strategy-context.ts b/src/pools/selection-strategies/worker-choice-strategy-context.ts index 6f15daa0..9a015347 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -1,4 +1,4 @@ -import { getDefaultInternalWorkerChoiceStrategyOptions } from '../../utils' +import { buildInternalWorkerChoiceStrategyOptions } from '../../utils' import type { IPool } from '../pool' import type { IWorker } from '../worker' import { FairShareWorkerChoiceStrategy } from './fair-share-worker-choice-strategy' @@ -46,12 +46,10 @@ export class WorkerChoiceStrategyContext< private workerChoiceStrategy: WorkerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN, private opts?: InternalWorkerChoiceStrategyOptions ) { - this.opts = { - ...getDefaultInternalWorkerChoiceStrategyOptions( - pool.info.maxSize + Object.keys(this.opts?.weights ?? {}).length - ), - ...this.opts - } + this.opts = buildInternalWorkerChoiceStrategyOptions( + pool.info.maxSize, + this.opts + ) this.execute = this.execute.bind(this) this.workerChoiceStrategies = new Map< WorkerChoiceStrategy, @@ -233,12 +231,10 @@ export class WorkerChoiceStrategyContext< pool: IPool, opts?: InternalWorkerChoiceStrategyOptions ): void { - this.opts = { - ...getDefaultInternalWorkerChoiceStrategyOptions( - pool.info.maxSize + Object.keys(opts?.weights ?? {}).length - ), - ...opts - } + this.opts = buildInternalWorkerChoiceStrategyOptions( + pool.info.maxSize, + opts + ) for (const workerChoiceStrategy of this.workerChoiceStrategies.values()) { workerChoiceStrategy.setOptions(this.opts) }