X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fselection-strategies-types.ts;h=9f68c22f892c50a3e424b59a3cb0cffe9f61557f;hb=eb7bf7441d410ca5d9ff9bb08f191ef22399371c;hp=26fe436d7a8e587b651458e8359a0b4d0a2e27f9;hpb=932fc8be063cc15b543ad14c2ab6df0fa4224fba;p=poolifier.git diff --git a/src/pools/selection-strategies/selection-strategies-types.ts b/src/pools/selection-strategies/selection-strategies-types.ts index 26fe436d..9f68c22f 100644 --- a/src/pools/selection-strategies/selection-strategies-types.ts +++ b/src/pools/selection-strategies/selection-strategies-types.ts @@ -14,6 +14,12 @@ export const WorkerChoiceStrategies = Object.freeze({ * Least busy worker selection strategy. */ LEAST_BUSY: 'LEAST_BUSY', + /** + * Least ELU worker selection strategy. + * + * @experimental + */ + LEAST_ELU: 'LEAST_ELU', /** * Fair share worker selection strategy. */ @@ -35,39 +41,63 @@ export const WorkerChoiceStrategies = Object.freeze({ */ export type WorkerChoiceStrategy = keyof typeof WorkerChoiceStrategies +/** + * Enumeration of measurements. + */ +export const Measurements = Object.freeze({ + runTime: 'runTime', + waitTime: 'waitTime', + elu: 'elu' +} as const) + +/** + * Measurement. + */ +export type Measurement = keyof typeof Measurements + /** * Measurement options. */ -interface MeasurementOptions { +export interface MeasurementOptions { /** * Set measurement median. */ - median: boolean + readonly median: boolean } /** * Worker choice strategy options. */ export interface WorkerChoiceStrategyOptions { + /** + * Measurement to use for worker choice strategy. + */ + readonly measurement?: Measurement /** * Runtime options. * * @defaultValue \{ median: false \} */ - runTime?: MeasurementOptions + readonly runTime?: MeasurementOptions /** * Wait time options. * * @defaultValue \{ median: false \} */ - waitTime?: MeasurementOptions + readonly waitTime?: MeasurementOptions + /** + * Event loop utilization options. + * + * @defaultValue \{ median: false \} + */ + readonly elu?: MeasurementOptions /** * Worker weights to use for weighted round robin worker selection strategy. * Weight is the tasks maximum average or median runtime in milliseconds. * * @defaultValue Computed worker weights automatically given the CPU performance. */ - weights?: Record + readonly weights?: Record } /** @@ -75,17 +105,17 @@ export interface WorkerChoiceStrategyOptions { * * @internal */ -interface MeasurementStatisticsRequirements { +export interface MeasurementStatisticsRequirements { /** - * Require measurement aggregate. + * Requires measurement aggregate. */ aggregate: boolean /** - * Require measurement average. + * Requires measurement average. */ average: boolean /** - * Require measurement median. + * Requires measurement median. */ median: boolean } @@ -99,21 +129,37 @@ export interface TaskStatisticsRequirements { /** * Tasks runtime requirements. */ - runTime: MeasurementStatisticsRequirements + readonly runTime: MeasurementStatisticsRequirements /** * Tasks wait time requirements. */ - waitTime: MeasurementStatisticsRequirements + readonly waitTime: MeasurementStatisticsRequirements + /** + * Tasks event loop utilization requirements. + */ + readonly elu: MeasurementStatisticsRequirements +} + +/** + * Strategy policy. + * + * @internal + */ +export interface StrategyPolicy { /** - * Event loop utilization. + * Expects direct usage of dynamic worker. */ - elu: boolean + readonly useDynamicWorker: boolean } /** * Worker choice strategy interface. */ export interface IWorkerChoiceStrategy { + /** + * Strategy policy. + */ + readonly strategyPolicy: StrategyPolicy /** * Tasks statistics requirements. */