X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fweighted-round-robin-worker-choice-strategy.ts;h=53b2d64d923412e73ae11f9b8cbc23f892acdf4a;hb=feec4213515cceb460e722dedca403914764b487;hp=c2782e8b2bf844b1a767eafcfe8554b0fc568ec7;hpb=da3098610d6cf6155bbbe53c84b6ac6ccd400ff5;p=poolifier.git diff --git a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts index c2782e8b..53b2d64d 100644 --- a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts @@ -1,6 +1,7 @@ import { cpus } from 'node:os' -import type { IPoolInternal } from '../pool-internal' import type { IWorker } from '../worker' +import type { IPool } from '../pool' +import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils' import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy' import type { IWorkerChoiceStrategy, @@ -22,7 +23,7 @@ interface TaskRunTime { * * @typeParam Worker - Type of worker which manages the strategy. * @typeParam Data - Type of data sent to the worker. This can only be serializable data. - * @typeParam Response - Type of response of execution. This can only be serializable data. + * @typeParam Response - Type of execution response. This can only be serializable data. */ export class WeightedRoundRobinWorkerChoiceStrategy< Worker extends IWorker, @@ -54,17 +55,13 @@ export class WeightedRoundRobinWorkerChoiceStrategy< TaskRunTime >() - /** - * Constructs a worker choice strategy that selects with a weighted round robin scheduling algorithm. - * - * @param pool - The pool instance. - * @param opts - The worker choice strategy options. - */ + /** @inheritDoc */ public constructor ( - pool: IPoolInternal, - opts?: WorkerChoiceStrategyOptions + pool: IPool, + opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS ) { super(pool, opts) + this.checkOptions(this.opts) this.defaultWorkerWeight = this.computeWorkerWeight() this.initWorkersTaskRunTime() }