X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fworker-choice-strategy-context.ts;h=9a015347bc2a430172855116224da8cfc89f2800;hb=8b3fccaac505706915540210b9d123e1a12e79ab;hp=50c3f9c854d4f7224358386fe943074aa8b909f7;hpb=26ce26ca8861318068427cc86697103e7a3ddbf4;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 50c3f9c8..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,10 +46,10 @@ export class WorkerChoiceStrategyContext< private workerChoiceStrategy: WorkerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN, private opts?: InternalWorkerChoiceStrategyOptions ) { - this.opts = { - ...getDefaultInternalWorkerChoiceStrategyOptions(pool.info.maxSize), - ...this.opts - } + this.opts = buildInternalWorkerChoiceStrategyOptions( + pool.info.maxSize, + this.opts + ) this.execute = this.execute.bind(this) this.workerChoiceStrategies = new Map< WorkerChoiceStrategy, @@ -224,16 +224,17 @@ export class WorkerChoiceStrategyContext< /** * Sets the worker choice strategies in the context options. * + * @param pool - The pool instance. * @param opts - The worker choice strategy options. */ public setOptions ( pool: IPool, opts?: InternalWorkerChoiceStrategyOptions ): void { - this.opts = { - ...getDefaultInternalWorkerChoiceStrategyOptions(pool.info.maxSize), - ...opts - } + this.opts = buildInternalWorkerChoiceStrategyOptions( + pool.info.maxSize, + opts + ) for (const workerChoiceStrategy of this.workerChoiceStrategies.values()) { workerChoiceStrategy.setOptions(this.opts) }