X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fworker-choice-strategy-context.ts;h=2bc99a7b47f14b86b0f43104723b1735f2eed0a1;hb=8f4c94912281e5a11eb6905538a56ed6ab7f51be;hp=f6e132c88514e3012dcf732cb01cde69a4b26410;hpb=87de9ff55a7ad494b9e9500208b9b7319c094ea6;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 f6e132c8..2bc99a7b 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -5,9 +5,11 @@ import { FairShareWorkerChoiceStrategy } from './fair-share-worker-choice-strate import { InterleavedWeightedRoundRobinWorkerChoiceStrategy } from './interleaved-weighted-round-robin-worker-choice-strategy' import { LeastBusyWorkerChoiceStrategy } from './least-busy-worker-choice-strategy' import { LeastUsedWorkerChoiceStrategy } from './least-used-worker-choice-strategy' +import { LeastEluWorkerChoiceStrategy } from './least-elu-worker-choice-strategy' import { RoundRobinWorkerChoiceStrategy } from './round-robin-worker-choice-strategy' import type { IWorkerChoiceStrategy, + StrategyPolicy, TaskStatisticsRequirements, WorkerChoiceStrategy, WorkerChoiceStrategyOptions @@ -19,8 +21,8 @@ import { WeightedRoundRobinWorkerChoiceStrategy } from './weighted-round-robin-w * The worker choice strategy context. * * @typeParam Worker - Type of worker. - * @typeParam Data - Type of data sent to the worker. This can only be serializable data. - * @typeParam Response - Type of execution response. This can only be serializable data. + * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data. + * @typeParam Response - Type of execution response. This can only be structured-cloneable data. */ export class WorkerChoiceStrategyContext< Worker extends IWorker, @@ -70,6 +72,13 @@ export class WorkerChoiceStrategyContext< opts ) ], + [ + WorkerChoiceStrategies.LEAST_ELU, + new (LeastEluWorkerChoiceStrategy.bind(this))( + pool, + opts + ) + ], [ WorkerChoiceStrategies.FAIR_SHARE, new (FairShareWorkerChoiceStrategy.bind(this))( @@ -96,6 +105,19 @@ export class WorkerChoiceStrategyContext< ]) } + /** + * Gets the strategy policy in the context. + * + * @returns The strategy policy. + */ + public getStrategyPolicy (): StrategyPolicy { + return ( + this.workerChoiceStrategies.get( + this.workerChoiceStrategy + ) as IWorkerChoiceStrategy + ).strategyPolicy + } + /** * Gets the worker choice strategy task statistics requirements in the context. *