X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicClusterPool.html;h=ae97fc9c47f17ba9f1c4a5f03a3d8e2956420eaf;hb=b2ec8632edaea1f4ee24a532e61ca6e5619b7bfb;hp=e27ae5eda86ac56158af4280a219e76c1938e18a;hpb=f04db52f666beefda86a0444fb9a28d410211b3f;p=poolifier.git diff --git a/docs/classes/DynamicClusterPool.html b/docs/classes/DynamicClusterPool.html index e27ae5ed..ae97fc9c 100644 --- a/docs/classes/DynamicClusterPool.html +++ b/docs/classes/DynamicClusterPool.html @@ -1,13 +1,13 @@ -
Optional
Readonly
emitter
Emitter on which events can be listened to.
+
+Optional
emitterEvent emitter integrated with async resource on which events can be listened to. +The async tracking tooling identifier is
poolifier:<PoolType>-<WorkerType>-pool
.Events that can currently be listened to:
-
-
+
+
+
+
'full'
: Emitted when the pool is dynamic and the number of workers created has reached the maximum size expected.'ready'
: Emitted when the number of workers created in the pool has reached the minimum size expected and are ready.'busy'
: Emitted when the number of workers created in the pool has reached the maximum size expected and are executing at least one task.'busy'
: Emitted when the number of workers created in the pool has reached the maximum size expected and are executing concurrently their tasks quota.'full'
: Emitted when the pool is dynamic and the number of workers created has reached the maximum size expected.'destroy'
: Emitted when the pool is destroyed.'error'
: Emitted when an uncaught error occurs.'taskError'
: Emitted when an error occurs while executing a task.'backPressure'
: Emitted when all worker nodes have back pressure (i.e. their tasks queue is full: queue size >= maximum queue size).Protected
Readonly
fileProtected
Readonly
maxMaximum number of workers that can be created by this pool.
Protected
Readonly
numberProtected
Readonly
optsProtected
promiseThe task execution response promise map.
+The task execution response promise map:
key
: The message id of each submitted task.value
: An object that contains the worker, the execution response promise resolve and reject callbacks.Protected
worker Nodes
+Readonly
workerReadonly
Internal
workerPool worker nodes.
Accessors
Protected
full@@ -261,7 +275,7 @@ When the maximum number of workers is reached and workers are busy, an event is
info
@@ -273,19 +287,19 @@ When the maximum number of workers is reached and workers are busy, an event is
Size
-Protected
max+- get maxSize(): number
-
The pool maximum size.
Returns number
Protected
min@@ -297,7 +311,7 @@ When the maximum number of workers is reached and workers are busy, an event is
Private
ready@@ -309,7 +323,7 @@ When the maximum number of workers is reached and workers are busy, an event is
Protected
type@@ -322,7 +336,7 @@ When the maximum number of workers is reached and workers are busy, an event is
Private
utilization@@ -335,21 +349,52 @@ When the maximum number of workers is reached and workers are busy, an event is
Protected
worker-- get worker(): "cluster" | "thread"
+- get worker(): "thread" | "cluster"
-
-
The worker type.
Returns "cluster" | "thread"
+Returns "thread" | "cluster"
Methods
+add Task Function
++- add
Task Function(name, fn): Promise<boolean>
+-
+
+
+
+
+
Adds a task function to this pool. +If a task function with the same name already exists, it will be overwritten.
+Parameters
++-
+
+
+-
+
+
name: string
+The name of the task function.
+fn: TaskFunction<Data, Response>
+The task function.
+Returns Promise<boolean>
+ +true
if the task function was added,false
otherwise.Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+ +name
parameter is not a string or an empty string.Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+fn
parameter is not a function.Protected
after@@ -375,7 +420,7 @@ Can be overridden.
Protected
after@@ -396,7 +441,7 @@ Can be overridden.
Protected
before@@ -422,23 +467,7 @@ Can be overridden.
Dynamic Pool Size
-Protected
check-- check
Dynamic Pool Size(min, max): void
--
-
-
-
Parameters
---
-
--
-
min: number
max: number
Returns void
Protected
create@@ -451,7 +480,7 @@ Can be overridden.
Protected
create@@ -464,7 +493,7 @@ Can be overridden.
Protected
create@@ -477,7 +506,48 @@ Can be overridden.
Worker Message Listener
+Protected
deregister+- deregister
Worker Message Listener<Message>(workerNodeKey, listener): void
+-
+
+
+
+
+
+
Deregisters a listener callback on the worker given its worker node key.
+Type Parameters
++-
+
Message
Parameters
++-
+
+
+-
+
+
+
workerNodeKey: number
+The worker node key.
+listener: ((message) => void)
+The message listener callback.
++-
+
+- (message): void
+-
+
+
+
Parameters
++-
+
message: MessageValue<Message, unknown>
Returns void
Returns void
+destroy
@@ -489,7 +559,7 @@ Can be overridden.
Protected
destroy@@ -509,36 +579,36 @@ Can be overridden.
enable Tasks Queue
Enables/disables the worker tasks queue in this pool.
+Enables/disables the worker node tasks queue in this pool.
Parameters
enable: boolean
-Whether to enable or disable the worker tasks queue.
+Whether to enable or disable the worker node tasks queue.
-Optional
tasksQueueOptions: TasksQueueOptionsThe worker tasks queue options.
+The worker node tasks queue options.
Returns void
execute
-- execute(data?, name?): Promise<Response>
+- execute(data?, name?, transferList?): Promise<Response>
-
@@ -547,12 +617,17 @@ Can be overridden.
-
-
+
+-
+
+- Defined in src/pools/abstract-pool.ts:879
+
+
Tasks Queue
+- Defined in src/pools/abstract-pool.ts:1696
Worker Info
+- Defined in src/pools/abstract-pool.ts:1608
+
+
+
+
Busy
- internal
Busy(): boolean
-
-
- Defined in src/pools/abstract-pool.ts:676
Main
+- Defined in src/pools/cluster/fixed.ts:58
+
+
+
+
Worker Message Listener
+- Defined in src/pools/cluster/fixed.ts:101
+
+
+
+
Startup Message To Worker
+- Defined in src/pools/cluster/fixed.ts:94
To Worker
+- Defined in src/pools/cluster/fixed.ts:83
+
+
- set
Tasks Queue Options(tasksQueueOptions): void
-
-
-
+- Defined in src/pools/abstract-pool.ts:578
+- Defined in src/pools/abstract-pool.ts:531
+- Defined in src/pools/abstract-pool.ts:550
Hook
-
-
+
+
+
-
-
\ No newline at end of file
+
Executes the specified function in the worker constructor with the task data input parameter.
-Optional
data: DataThe task input data for the specified worker function. This can only be structured-cloneable data.
+The optional task input data for the specified task function. This can only be structured-cloneable data.
-Optional
name: stringThe name of the worker function to execute. If not specified, the default worker function will be executed.
+The optional name of the task function to execute. If not specified, the default task function will be executed.
+
+Optional
transferList: TransferListItem[]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.
Returns Promise<Response>
Promise that will be fulfilled when the task is completed.
@@ -560,7 +635,21 @@ Can be overridden. Worker Node As Not Ready
+Protected
flag+- flag
Worker Node As Not Ready(workerNodeKey): void
+-
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns void
Protected
flush@@ -574,7 +663,7 @@ Can be overridden.
Returns void
Protected
get@@ -595,20 +684,62 @@ Can be overridden.
has Task Function
++- has
Task Function(name): boolean
+-
+
+
+
+
Whether the specified task function exists in this pool.
+Parameters
++-
+
+
name: string
+The name of the task function.
+Returns boolean
+ +true
if the task function exists,false
otherwise.has Worker Node Back Pressure
++- has
Worker Node Back Pressure(workerNodeKey): boolean
+
+
+
+
Internal
+Whether the worker node has back pressure (i.e. its tasks queue is full).
+Parameters
++-
+
+
workerNodeKey: number
+The worker node key.
+Returns boolean
+ +true
if the worker node has back pressure,false
otherwise.Protected
internalWhether worker nodes are executing at least one task.
+Whether worker nodes are executing concurrently their tasks quota or not.
Returns boolean
Worker nodes busyness boolean status.
+Protected
is@@ -620,7 +751,61 @@ Can be overridden.
list Task Function Names
++- list
Task Function Names(): string[]
+-
+
+
Lists the names of task function available in this pool.
+Returns string[]
The names of task function available in this pool.
+ + Once Worker Message Listener
+Protected
register+- register
Once Worker Message Listener<Message>(workerNodeKey, listener): void
+-
+
+
+
+
+
+
Registers once a listener callback on the worker given its worker node key.
+Type Parameters
++-
+
Message
Parameters
++-
+
+
+-
+
+
+
workerNodeKey: number
+The worker node key.
+listener: ((message) => void)
+The message listener callback.
++-
+
+- (message): void
+-
+
+
+
Parameters
++-
+
message: MessageValue<Message, unknown>
Returns void
Returns void
+Protected
register@@ -661,7 +846,42 @@ Can be overridden.
remove Task Function
++- remove
Task Function(name): Promise<boolean>
+-
+
+
+
+
Removes a task function from this pool.
+Parameters
++-
+
+
name: string
+The name of the task function.
+Returns Promise<boolean>
+ +true
if the task function was removed,false
otherwise. Kill Message To Worker
+Protected
send+- send
Kill Message To Worker(workerNodeKey): Promise<void>
+-
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns Promise<void>
Protected
send@@ -681,7 +901,7 @@ Can be overridden.
Protected
send@@ -706,27 +926,48 @@ Can be overridden.
set Default Task Function
++- set
Default Task Function(name): Promise<boolean>
+-
+
+
+
+
Sets the default task function in this pool.
+Parameters
++-
+
+
name: string
+The name of the task function.
+Returns Promise<boolean>
+ +true
if the default task function was set,false
otherwise.set Tasks Queue Options
Sets the worker tasks queue options in this pool.
+Sets the worker node tasks queue options in this pool.
Parameters
tasksQueueOptions: TasksQueueOptions
-The worker tasks queue options.
+The worker node tasks queue options.
Returns void
set Worker Choice Strategy
@@ -751,7 +992,7 @@ Can be overridden.
set Worker Choice Strategy Options
@@ -771,7 +1012,7 @@ Can be overridden.
Protected
setup@@ -784,40 +1025,41 @@ Can be overridden.
Listener
-Protected
worker-- worker
Listener(): ((message) => void)
+- Defined in src/pools/cluster/fixed.ts:53
start
++- start(): void
-
-
-
+
+- start
+- worker
Message Listener
-
This method is the listener registered for each worker message.
+Starts the minimum number of workers in this pool.
Returns ((message) => void)
The listener function to execute when a message is received from a worker.
- ---
-
+-- (message): void
+
Returns void
+ Message Listener
+Protected
worker+- worker
Message Listener(message): void
-
-
-
-
+ - Defined in src/pools/abstract-pool.ts:1518
This method is the listener registered for each worker message.
+This method is the message listener registered on each worker.
Parameters
message: MessageValue<Response, unknown>
Returns void
The listener function to execute when a message is received from a worker.
- - +Returns void
-
+Settings
Settings
Member Visibility
Generated using TypeDoc
Generated using TypeDoc