poolifier 2.6.36 → 2.6.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +6 -3
  2. package/lib/index.d.ts +1881 -22
  3. package/lib/index.js +1 -1
  4. package/lib/index.mjs +1 -1
  5. package/package.json +8 -7
  6. package/lib/circular-array.d.ts +0 -22
  7. package/lib/deque.d.ts +0 -80
  8. package/lib/pools/abstract-pool.d.ts +0 -314
  9. package/lib/pools/cluster/dynamic.d.ts +0 -29
  10. package/lib/pools/cluster/fixed.d.ts +0 -62
  11. package/lib/pools/pool.d.ts +0 -243
  12. package/lib/pools/selection-strategies/abstract-worker-choice-strategy.d.ts +0 -104
  13. package/lib/pools/selection-strategies/fair-share-worker-choice-strategy.d.ts +0 -39
  14. package/lib/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.d.ts +0 -39
  15. package/lib/pools/selection-strategies/least-busy-worker-choice-strategy.d.ts +0 -26
  16. package/lib/pools/selection-strategies/least-elu-worker-choice-strategy.d.ts +0 -26
  17. package/lib/pools/selection-strategies/least-used-worker-choice-strategy.d.ts +0 -24
  18. package/lib/pools/selection-strategies/round-robin-worker-choice-strategy.d.ts +0 -24
  19. package/lib/pools/selection-strategies/selection-strategies-types.d.ts +0 -200
  20. package/lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.d.ts +0 -35
  21. package/lib/pools/selection-strategies/worker-choice-strategy-context.d.ts +0 -71
  22. package/lib/pools/thread/dynamic.d.ts +0 -29
  23. package/lib/pools/thread/fixed.d.ts +0 -54
  24. package/lib/pools/version.d.ts +0 -1
  25. package/lib/pools/worker-node.d.ts +0 -69
  26. package/lib/pools/worker.d.ts +0 -276
  27. package/lib/utility-types.d.ts +0 -152
  28. package/lib/utils.d.ts +0 -115
  29. package/lib/worker/abstract-worker.d.ts +0 -191
  30. package/lib/worker/cluster-worker.d.ts +0 -35
  31. package/lib/worker/task-functions.d.ts +0 -33
  32. package/lib/worker/thread-worker.d.ts +0 -43
  33. package/lib/worker/worker-options.d.ts +0 -61
@@ -1,243 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { EventEmitter } from 'node:events';
4
- import { type TransferListItem } from 'node:worker_threads';
5
- import type { ErrorHandler, ExitHandler, IWorker, IWorkerNode, MessageHandler, OnlineHandler, WorkerType } from './worker';
6
- import type { WorkerChoiceStrategy, WorkerChoiceStrategyOptions } from './selection-strategies/selection-strategies-types';
7
- /**
8
- * Enumeration of pool types.
9
- */
10
- export declare const PoolTypes: Readonly<{
11
- /**
12
- * Fixed pool type.
13
- */
14
- readonly fixed: "fixed";
15
- /**
16
- * Dynamic pool type.
17
- */
18
- readonly dynamic: "dynamic";
19
- }>;
20
- /**
21
- * Pool type.
22
- */
23
- export type PoolType = keyof typeof PoolTypes;
24
- /**
25
- * Pool events emitter.
26
- */
27
- export declare class PoolEmitter extends EventEmitter {
28
- }
29
- /**
30
- * Enumeration of pool events.
31
- */
32
- export declare const PoolEvents: Readonly<{
33
- readonly ready: "ready";
34
- readonly busy: "busy";
35
- readonly full: "full";
36
- readonly destroy: "destroy";
37
- readonly error: "error";
38
- readonly taskError: "taskError";
39
- readonly backPressure: "backPressure";
40
- }>;
41
- /**
42
- * Pool event.
43
- */
44
- export type PoolEvent = keyof typeof PoolEvents;
45
- /**
46
- * Pool information.
47
- */
48
- export interface PoolInfo {
49
- readonly version: string;
50
- readonly type: PoolType;
51
- readonly worker: WorkerType;
52
- readonly ready: boolean;
53
- readonly strategy: WorkerChoiceStrategy;
54
- readonly minSize: number;
55
- readonly maxSize: number;
56
- /** Pool utilization. */
57
- readonly utilization?: number;
58
- /** Pool total worker nodes. */
59
- readonly workerNodes: number;
60
- /** Pool idle worker nodes. */
61
- readonly idleWorkerNodes: number;
62
- /** Pool busy worker nodes. */
63
- readonly busyWorkerNodes: number;
64
- readonly executedTasks: number;
65
- readonly executingTasks: number;
66
- readonly queuedTasks?: number;
67
- readonly maxQueuedTasks?: number;
68
- readonly backPressure?: boolean;
69
- readonly stolenTasks?: number;
70
- readonly failedTasks: number;
71
- readonly runTime?: {
72
- readonly minimum: number;
73
- readonly maximum: number;
74
- readonly average?: number;
75
- readonly median?: number;
76
- };
77
- readonly waitTime?: {
78
- readonly minimum: number;
79
- readonly maximum: number;
80
- readonly average?: number;
81
- readonly median?: number;
82
- };
83
- }
84
- /**
85
- * Worker node tasks queue options.
86
- */
87
- export interface TasksQueueOptions {
88
- /**
89
- * Maximum tasks queue size per worker node flagging it as back pressured.
90
- *
91
- * @defaultValue (pool maximum size)^2
92
- */
93
- readonly size?: number;
94
- /**
95
- * @deprecated Use `size` instead.
96
- */
97
- readonly queueMaxSize?: number;
98
- /**
99
- * Maximum number of tasks that can be executed concurrently on a worker node.
100
- *
101
- * @defaultValue 1
102
- */
103
- readonly concurrency?: number;
104
- }
105
- /**
106
- * Options for a poolifier pool.
107
- *
108
- * @typeParam Worker - Type of worker.
109
- */
110
- export interface PoolOptions<Worker extends IWorker> {
111
- /**
112
- * A function that will listen for online event on each worker.
113
- */
114
- onlineHandler?: OnlineHandler<Worker>;
115
- /**
116
- * A function that will listen for message event on each worker.
117
- */
118
- messageHandler?: MessageHandler<Worker>;
119
- /**
120
- * A function that will listen for error event on each worker.
121
- */
122
- errorHandler?: ErrorHandler<Worker>;
123
- /**
124
- * A function that will listen for exit event on each worker.
125
- */
126
- exitHandler?: ExitHandler<Worker>;
127
- /**
128
- * The worker choice strategy to use in this pool.
129
- *
130
- * @defaultValue WorkerChoiceStrategies.ROUND_ROBIN
131
- */
132
- workerChoiceStrategy?: WorkerChoiceStrategy;
133
- /**
134
- * The worker choice strategy options.
135
- */
136
- workerChoiceStrategyOptions?: WorkerChoiceStrategyOptions;
137
- /**
138
- * Restart worker on error.
139
- */
140
- restartWorkerOnError?: boolean;
141
- /**
142
- * Pool events emission.
143
- *
144
- * @defaultValue true
145
- */
146
- enableEvents?: boolean;
147
- /**
148
- * Pool worker node tasks queue.
149
- *
150
- * @defaultValue false
151
- */
152
- enableTasksQueue?: boolean;
153
- /**
154
- * Pool worker node tasks queue options.
155
- */
156
- tasksQueueOptions?: TasksQueueOptions;
157
- }
158
- /**
159
- * Contract definition for a poolifier pool.
160
- *
161
- * @typeParam Worker - Type of worker which manages this pool.
162
- * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
163
- * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
164
- */
165
- export interface IPool<Worker extends IWorker, Data = unknown, Response = unknown> {
166
- /**
167
- * Pool information.
168
- */
169
- readonly info: PoolInfo;
170
- /**
171
- * Pool worker nodes.
172
- *
173
- * @internal
174
- */
175
- readonly workerNodes: Array<IWorkerNode<Worker, Data>>;
176
- /**
177
- * Whether the worker node has back pressure (i.e. its tasks queue is full).
178
- *
179
- * @param workerNodeKey - The worker node key.
180
- * @returns `true` if the worker node has back pressure, `false` otherwise.
181
- * @internal
182
- */
183
- readonly hasWorkerNodeBackPressure: (workerNodeKey: number) => boolean;
184
- /**
185
- * Emitter on which events can be listened to.
186
- *
187
- * Events that can currently be listened to:
188
- *
189
- * - `'ready'`: Emitted when the number of workers created in the pool has reached the minimum size expected and are ready.
190
- * - `'busy'`: Emitted when the number of workers created in the pool has reached the maximum size expected and are executing at least one task.
191
- * - `'full'`: Emitted when the pool is dynamic and the number of workers created has reached the maximum size expected.
192
- * - `'destroy'`: Emitted when the pool is destroyed.
193
- * - `'error'`: Emitted when an uncaught error occurs.
194
- * - `'taskError'`: Emitted when an error occurs while executing a task.
195
- * - `'backPressure'`: Emitted when all worker nodes have back pressure (i.e. their tasks queue is full: queue size \>= maximum queue size).
196
- */
197
- readonly emitter?: PoolEmitter;
198
- /**
199
- * Executes the specified function in the worker constructor with the task data input parameter.
200
- *
201
- * @param data - The optional task input data for the specified task function. This can only be structured-cloneable data.
202
- * @param name - The optional name of the task function to execute. If not specified, the default task function will be executed.
203
- * @param transferList - An optional array of transferable objects to transfer ownership of. Ownership of the transferred objects is given to the pool's worker_threads worker and they should not be used in the main thread afterwards.
204
- * @returns Promise that will be fulfilled when the task is completed.
205
- */
206
- readonly execute: (data?: Data, name?: string, transferList?: TransferListItem[]) => Promise<Response>;
207
- /**
208
- * Terminates all workers in this pool.
209
- */
210
- readonly destroy: () => Promise<void>;
211
- /**
212
- * Lists the names of task function available in this pool.
213
- *
214
- * @returns The names of task function available in this pool.
215
- */
216
- readonly listTaskFunctions: () => string[];
217
- /**
218
- * Sets the worker choice strategy in this pool.
219
- *
220
- * @param workerChoiceStrategy - The worker choice strategy.
221
- * @param workerChoiceStrategyOptions - The worker choice strategy options.
222
- */
223
- readonly setWorkerChoiceStrategy: (workerChoiceStrategy: WorkerChoiceStrategy, workerChoiceStrategyOptions?: WorkerChoiceStrategyOptions) => void;
224
- /**
225
- * Sets the worker choice strategy options in this pool.
226
- *
227
- * @param workerChoiceStrategyOptions - The worker choice strategy options.
228
- */
229
- readonly setWorkerChoiceStrategyOptions: (workerChoiceStrategyOptions: WorkerChoiceStrategyOptions) => void;
230
- /**
231
- * Enables/disables the worker node tasks queue in this pool.
232
- *
233
- * @param enable - Whether to enable or disable the worker node tasks queue.
234
- * @param tasksQueueOptions - The worker node tasks queue options.
235
- */
236
- readonly enableTasksQueue: (enable: boolean, tasksQueueOptions?: TasksQueueOptions) => void;
237
- /**
238
- * Sets the worker node tasks queue options in this pool.
239
- *
240
- * @param tasksQueueOptions - The worker node tasks queue options.
241
- */
242
- readonly setTasksQueueOptions: (tasksQueueOptions: TasksQueueOptions) => void;
243
- }
@@ -1,104 +0,0 @@
1
- import type { IPool } from '../pool';
2
- import type { IWorker } from '../worker';
3
- import type { IWorkerChoiceStrategy, StrategyPolicy, TaskStatisticsRequirements, WorkerChoiceStrategyOptions } from './selection-strategies-types';
4
- /**
5
- * Worker choice strategy abstract base class.
6
- *
7
- * @typeParam Worker - Type of worker which manages the strategy.
8
- * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
9
- * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
10
- */
11
- export declare abstract class AbstractWorkerChoiceStrategy<Worker extends IWorker, Data = unknown, Response = unknown> implements IWorkerChoiceStrategy {
12
- protected readonly pool: IPool<Worker, Data, Response>;
13
- protected opts: WorkerChoiceStrategyOptions;
14
- /**
15
- * The next worker node key.
16
- */
17
- protected nextWorkerNodeKey: number | undefined;
18
- /**
19
- * The previous worker node key.
20
- */
21
- protected previousWorkerNodeKey: number;
22
- /** @inheritDoc */
23
- readonly strategyPolicy: StrategyPolicy;
24
- /** @inheritDoc */
25
- readonly taskStatisticsRequirements: TaskStatisticsRequirements;
26
- /**
27
- * Constructs a worker choice strategy bound to the pool.
28
- *
29
- * @param pool - The pool instance.
30
- * @param opts - The worker choice strategy options.
31
- */
32
- constructor(pool: IPool<Worker, Data, Response>, opts?: WorkerChoiceStrategyOptions);
33
- protected setTaskStatisticsRequirements(opts: WorkerChoiceStrategyOptions): void;
34
- private toggleMedianMeasurementStatisticsRequirements;
35
- protected resetWorkerNodeKeyProperties(): void;
36
- /** @inheritDoc */
37
- abstract reset(): boolean;
38
- /** @inheritDoc */
39
- abstract update(workerNodeKey: number): boolean;
40
- /** @inheritDoc */
41
- abstract choose(): number | undefined;
42
- /** @inheritDoc */
43
- abstract remove(workerNodeKey: number): boolean;
44
- /** @inheritDoc */
45
- setOptions(opts: WorkerChoiceStrategyOptions): void;
46
- /**
47
- * Whether the worker node is ready or not.
48
- *
49
- * @param workerNodeKey - The worker node key.
50
- * @returns Whether the worker node is ready or not.
51
- */
52
- private isWorkerNodeReady;
53
- /**
54
- * Whether the worker node has back pressure or not (i.e. its tasks queue is full).
55
- *
56
- * @param workerNodeKey - The worker node key.
57
- * @returns `true` if the worker node has back pressure, `false` otherwise.
58
- */
59
- private hasWorkerNodeBackPressure;
60
- /**
61
- * Whether the worker node is eligible or not.
62
- * A worker node is eligible if it is ready and does not have back pressure.
63
- *
64
- * @param workerNodeKey - The worker node key.
65
- * @returns `true` if the worker node is eligible, `false` otherwise.
66
- * @see {@link isWorkerNodeReady}
67
- * @see {@link hasWorkerNodeBackPressure}
68
- */
69
- protected isWorkerNodeEligible(workerNodeKey: number): boolean;
70
- /**
71
- * Gets the worker task runtime.
72
- * If the task statistics require the average runtime, the average runtime is returned.
73
- * If the task statistics require the median runtime , the median runtime is returned.
74
- *
75
- * @param workerNodeKey - The worker node key.
76
- * @returns The worker task runtime.
77
- */
78
- protected getWorkerTaskRunTime(workerNodeKey: number): number;
79
- /**
80
- * Gets the worker task wait time.
81
- * If the task statistics require the average wait time, the average wait time is returned.
82
- * If the task statistics require the median wait time, the median wait time is returned.
83
- *
84
- * @param workerNodeKey - The worker node key.
85
- * @returns The worker task wait time.
86
- */
87
- protected getWorkerTaskWaitTime(workerNodeKey: number): number;
88
- /**
89
- * Gets the worker task ELU.
90
- * If the task statistics require the average ELU, the average ELU is returned.
91
- * If the task statistics require the median ELU, the median ELU is returned.
92
- *
93
- * @param workerNodeKey - The worker node key.
94
- * @returns The worker task ELU.
95
- */
96
- protected getWorkerTaskElu(workerNodeKey: number): number;
97
- /**
98
- * Check the next worker node eligibility.
99
- *
100
- * @param chosenNextWorkerNodeKey - The chosen worker node key.
101
- */
102
- protected checkNextWorkerNodeEligibility(chosenNextWorkerNodeKey: number | undefined): void;
103
- protected computeDefaultWorkerWeight(): number;
104
- }
@@ -1,39 +0,0 @@
1
- import type { IPool } from '../pool';
2
- import type { IWorker } from '../worker';
3
- import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy';
4
- import { type IWorkerChoiceStrategy, type TaskStatisticsRequirements, type WorkerChoiceStrategyOptions } from './selection-strategies-types';
5
- /**
6
- * Selects the next worker with a fair share scheduling algorithm.
7
- * Loosely modeled after the fair queueing algorithm: https://en.wikipedia.org/wiki/Fair_queuing.
8
- *
9
- * @typeParam Worker - Type of worker which manages the strategy.
10
- * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
11
- * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
12
- */
13
- export declare class FairShareWorkerChoiceStrategy<Worker extends IWorker, Data = unknown, Response = unknown> extends AbstractWorkerChoiceStrategy<Worker, Data, Response> implements IWorkerChoiceStrategy {
14
- /** @inheritDoc */
15
- readonly taskStatisticsRequirements: TaskStatisticsRequirements;
16
- /**
17
- * Workers' virtual task end execution timestamp.
18
- */
19
- private workersVirtualTaskEndTimestamp;
20
- /** @inheritDoc */
21
- constructor(pool: IPool<Worker, Data, Response>, opts?: WorkerChoiceStrategyOptions);
22
- /** @inheritDoc */
23
- reset(): boolean;
24
- /** @inheritDoc */
25
- update(workerNodeKey: number): boolean;
26
- /** @inheritDoc */
27
- choose(): number | undefined;
28
- /** @inheritDoc */
29
- remove(workerNodeKey: number): boolean;
30
- private fairShareNextWorkerNodeKey;
31
- /**
32
- * Computes the worker node key virtual task end timestamp.
33
- *
34
- * @param workerNodeKey - The worker node key.
35
- */
36
- private computeWorkerVirtualTaskEndTimestamp;
37
- private getWorkerVirtualTaskEndTimestamp;
38
- private getWorkerVirtualTaskStartTimestamp;
39
- }
@@ -1,39 +0,0 @@
1
- import type { IWorker } from '../worker';
2
- import type { IPool } from '../pool';
3
- import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy';
4
- import type { IWorkerChoiceStrategy, WorkerChoiceStrategyOptions } from './selection-strategies-types';
5
- /**
6
- * Selects the next worker with an interleaved weighted round robin scheduling algorithm.
7
- *
8
- * @typeParam Worker - Type of worker which manages the strategy.
9
- * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
10
- * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
11
- */
12
- export declare class InterleavedWeightedRoundRobinWorkerChoiceStrategy<Worker extends IWorker, Data = unknown, Response = unknown> extends AbstractWorkerChoiceStrategy<Worker, Data, Response> implements IWorkerChoiceStrategy {
13
- /**
14
- * Round id.
15
- * This is used to determine the current round weight.
16
- */
17
- private roundId;
18
- /**
19
- * Round weights.
20
- */
21
- private roundWeights;
22
- /**
23
- * Default worker weight.
24
- */
25
- private readonly defaultWorkerWeight;
26
- /** @inheritDoc */
27
- constructor(pool: IPool<Worker, Data, Response>, opts?: WorkerChoiceStrategyOptions);
28
- /** @inheritDoc */
29
- reset(): boolean;
30
- /** @inheritDoc */
31
- update(): boolean;
32
- /** @inheritDoc */
33
- choose(): number | undefined;
34
- /** @inheritDoc */
35
- remove(workerNodeKey: number): boolean;
36
- /** @inheritDoc */
37
- setOptions(opts: WorkerChoiceStrategyOptions): void;
38
- private getRoundWeights;
39
- }
@@ -1,26 +0,0 @@
1
- import type { IPool } from '../pool';
2
- import type { IWorker } from '../worker';
3
- import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy';
4
- import type { IWorkerChoiceStrategy, TaskStatisticsRequirements, WorkerChoiceStrategyOptions } from './selection-strategies-types';
5
- /**
6
- * Selects the least busy worker.
7
- *
8
- * @typeParam Worker - Type of worker which manages the strategy.
9
- * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
10
- * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
11
- */
12
- export declare class LeastBusyWorkerChoiceStrategy<Worker extends IWorker, Data = unknown, Response = unknown> extends AbstractWorkerChoiceStrategy<Worker, Data, Response> implements IWorkerChoiceStrategy {
13
- /** @inheritDoc */
14
- readonly taskStatisticsRequirements: TaskStatisticsRequirements;
15
- /** @inheritDoc */
16
- constructor(pool: IPool<Worker, Data, Response>, opts?: WorkerChoiceStrategyOptions);
17
- /** @inheritDoc */
18
- reset(): boolean;
19
- /** @inheritDoc */
20
- update(): boolean;
21
- /** @inheritDoc */
22
- choose(): number | undefined;
23
- /** @inheritDoc */
24
- remove(): boolean;
25
- private leastBusyNextWorkerNodeKey;
26
- }
@@ -1,26 +0,0 @@
1
- import type { IPool } from '../pool';
2
- import type { IWorker } from '../worker';
3
- import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy';
4
- import type { IWorkerChoiceStrategy, TaskStatisticsRequirements, WorkerChoiceStrategyOptions } from './selection-strategies-types';
5
- /**
6
- * Selects the worker with the least ELU.
7
- *
8
- * @typeParam Worker - Type of worker which manages the strategy.
9
- * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
10
- * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
11
- */
12
- export declare class LeastEluWorkerChoiceStrategy<Worker extends IWorker, Data = unknown, Response = unknown> extends AbstractWorkerChoiceStrategy<Worker, Data, Response> implements IWorkerChoiceStrategy {
13
- /** @inheritDoc */
14
- readonly taskStatisticsRequirements: TaskStatisticsRequirements;
15
- /** @inheritDoc */
16
- constructor(pool: IPool<Worker, Data, Response>, opts?: WorkerChoiceStrategyOptions);
17
- /** @inheritDoc */
18
- reset(): boolean;
19
- /** @inheritDoc */
20
- update(): boolean;
21
- /** @inheritDoc */
22
- choose(): number | undefined;
23
- /** @inheritDoc */
24
- remove(): boolean;
25
- private leastEluNextWorkerNodeKey;
26
- }
@@ -1,24 +0,0 @@
1
- import type { IPool } from '../pool';
2
- import type { IWorker } from '../worker';
3
- import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy';
4
- import type { IWorkerChoiceStrategy, WorkerChoiceStrategyOptions } from './selection-strategies-types';
5
- /**
6
- * Selects the least used worker.
7
- *
8
- * @typeParam Worker - Type of worker which manages the strategy.
9
- * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
10
- * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
11
- */
12
- export declare class LeastUsedWorkerChoiceStrategy<Worker extends IWorker, Data = unknown, Response = unknown> extends AbstractWorkerChoiceStrategy<Worker, Data, Response> implements IWorkerChoiceStrategy {
13
- /** @inheritDoc */
14
- constructor(pool: IPool<Worker, Data, Response>, opts?: WorkerChoiceStrategyOptions);
15
- /** @inheritDoc */
16
- reset(): boolean;
17
- /** @inheritDoc */
18
- update(): boolean;
19
- /** @inheritDoc */
20
- choose(): number | undefined;
21
- /** @inheritDoc */
22
- remove(): boolean;
23
- private leastUsedNextWorkerNodeKey;
24
- }
@@ -1,24 +0,0 @@
1
- import type { IPool } from '../pool';
2
- import type { IWorker } from '../worker';
3
- import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy';
4
- import type { IWorkerChoiceStrategy, WorkerChoiceStrategyOptions } from './selection-strategies-types';
5
- /**
6
- * Selects the next worker in a round robin fashion.
7
- *
8
- * @typeParam Worker - Type of worker which manages the strategy.
9
- * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
10
- * @typeParam Response - Type of execution response. This can only be structured-cloneable data.
11
- */
12
- export declare class RoundRobinWorkerChoiceStrategy<Worker extends IWorker, Data = unknown, Response = unknown> extends AbstractWorkerChoiceStrategy<Worker, Data, Response> implements IWorkerChoiceStrategy {
13
- /** @inheritDoc */
14
- constructor(pool: IPool<Worker, Data, Response>, opts?: WorkerChoiceStrategyOptions);
15
- /** @inheritDoc */
16
- reset(): boolean;
17
- /** @inheritDoc */
18
- update(): boolean;
19
- /** @inheritDoc */
20
- choose(): number | undefined;
21
- /** @inheritDoc */
22
- remove(workerNodeKey: number): boolean;
23
- private roundRobinNextWorkerNodeKey;
24
- }