2 * Enumeration of worker choice strategies.
4 export const WorkerChoiceStrategies
= Object.freeze({
6 * Round robin worker selection strategy.
8 ROUND_ROBIN
: 'ROUND_ROBIN',
10 * Less used worker selection strategy.
12 LESS_USED
: 'LESS_USED',
14 * Less busy worker selection strategy.
16 LESS_BUSY
: 'LESS_BUSY',
18 * Fair share worker selection strategy.
20 FAIR_SHARE
: 'FAIR_SHARE',
22 * Weighted round robin worker selection strategy.
24 WEIGHTED_ROUND_ROBIN
: 'WEIGHTED_ROUND_ROBIN'
28 * Worker choice strategy.
30 export type WorkerChoiceStrategy
= keyof
typeof WorkerChoiceStrategies
33 * Worker choice strategy options.
35 export interface WorkerChoiceStrategyOptions
{
37 * Use tasks median run time instead of average run time.
45 * Pool worker tasks usage statistics requirements.
49 export interface RequiredStatistics
{
51 * Require tasks run time.
55 * Require tasks average run time.
59 * Require tasks median run time.
65 * Worker choice strategy interface.
67 export interface IWorkerChoiceStrategy
{
69 * Required tasks usage statistics.
71 readonly requiredStatistics
: RequiredStatistics
73 * Resets strategy internals (counters, statistics, etc.).
77 * Chooses a worker node in the pool and returns its key.
81 * Removes a worker node key from strategy internals.
83 * @param workerNodeKey - The worker node key.
85 remove
: (workerNodeKey
: number) => boolean
87 * Sets the worker choice strategy options.
89 * @param opts - The worker choice strategy options.
91 setOptions
: (opts
: WorkerChoiceStrategyOptions
) => void