4d302f3defb1e7d5619d37693daf4104c944f377
1 import type { AbstractPoolWorker
} from
'../abstract-pool-worker'
4 * Enumeration of worker choice strategies.
6 export const WorkerChoiceStrategies
= Object.freeze({
8 * Round robin worker selection strategy.
10 ROUND_ROBIN
: 'ROUND_ROBIN',
12 * Less recently used worker selection strategy.
14 LESS_RECENTLY_USED
: 'LESS_RECENTLY_USED',
16 * Fair share worker selection strategy.
18 FAIR_SHARE
: 'FAIR_SHARE',
20 * Weighted round robin worker selection strategy.
22 WEIGHTED_ROUND_ROBIN
: 'WEIGHTED_ROUND_ROBIN'
26 * Worker choice strategy.
28 export type WorkerChoiceStrategy
= keyof
typeof WorkerChoiceStrategies
31 * Tasks usage statistics requirements.
33 export type RequiredStatistics
= {
38 * Worker choice strategy interface.
40 * @template Worker Type of worker which manages the strategy.
42 export interface IWorkerChoiceStrategy
<Worker
extends AbstractPoolWorker
> {
44 * Is the pool attached to the strategy dynamic?.
46 isDynamicPool
: boolean
48 * Required tasks usage statistics.
50 requiredStatistics
: RequiredStatistics
52 * Choose a worker in the pool.