X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fworker-choice-strategy-context.ts;h=43bcb3adee19a9aaedf072e526f0b59235e55b40;hb=69f3db74b7903c684a5e95ef00c6ab1f6aa098f8;hp=9ea46316becf64161e4f7736550bae465d22bf7e;hpb=720b5f8fb8094639055da32ed9b9139ded4450ac;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 9ea46316..43bcb3ad 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -3,8 +3,8 @@ import type { IPool } from '../pool' import type { IWorker } from '../worker' import { FairShareWorkerChoiceStrategy } from './fair-share-worker-choice-strategy' import { InterleavedWeightedRoundRobinWorkerChoiceStrategy } from './interleaved-weighted-round-robin-worker-choice-strategy' -import { LessBusyWorkerChoiceStrategy } from './less-busy-worker-choice-strategy' -import { LessUsedWorkerChoiceStrategy } from './less-used-worker-choice-strategy' +import { LeastBusyWorkerChoiceStrategy } from './least-busy-worker-choice-strategy' +import { LeastUsedWorkerChoiceStrategy } from './least-used-worker-choice-strategy' import { RoundRobinWorkerChoiceStrategy } from './round-robin-worker-choice-strategy' import type { IWorkerChoiceStrategy, @@ -57,15 +57,15 @@ export class WorkerChoiceStrategyContext< ) ], [ - WorkerChoiceStrategies.LESS_USED, - new (LessUsedWorkerChoiceStrategy.bind(this))( + WorkerChoiceStrategies.LEAST_USED, + new (LeastUsedWorkerChoiceStrategy.bind(this))( pool, opts ) ], [ - WorkerChoiceStrategies.LESS_BUSY, - new (LessBusyWorkerChoiceStrategy.bind(this))( + WorkerChoiceStrategies.LEAST_BUSY, + new (LeastBusyWorkerChoiceStrategy.bind(this))( pool, opts ) @@ -140,7 +140,7 @@ export class WorkerChoiceStrategyContext< * Executes the worker choice strategy algorithm in the context. * * @returns The key of the worker node. - * @throws {@link Error} If the worker node key is null or undefined. + * @throws {@link https://nodejs.org/api/errors.html#class-error} If the worker node key is null or undefined. */ public execute (): number { const workerNodeKey = ( @@ -174,8 +174,8 @@ export class WorkerChoiceStrategyContext< * @param opts - The worker choice strategy options. */ public setOptions (opts: WorkerChoiceStrategyOptions): void { - this.workerChoiceStrategies.forEach(workerChoiceStrategy => { + for (const workerChoiceStrategy of this.workerChoiceStrategies.values()) { workerChoiceStrategy.setOptions(opts) - }) + } } }