X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicClusterPool.html;h=1767983b04add9aa7d5360d287e04c72716bb93a;hb=34aa5747c72ab1952481eecf2932361fd8b49d01;hp=9b0467c126feed81e47947a884ab1e883e49cc1c;hpb=85003dff831b309b12d624215a8d67634af82b50;p=poolifier.git diff --git a/docs/classes/DynamicClusterPool.html b/docs/classes/DynamicClusterPool.html index 9b0467c1..1767983b 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
opts Response Map
-Protected
promiseThe 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@@ -258,7 +275,7 @@ When the maximum number of workers is reached and workers are busy, an event is
info
@@ -270,93 +287,118 @@ When the maximum number of workers is reached and workers are busy, an event is
Size
-Protected
max+- get maxSize(): number
-
-
- Defined in src/pools/abstract-pool.ts:485
Size
- get minSize(): number
-
-
- Defined in src/pools/abstract-pool.ts:478
- get ready(): boolean
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:430
- get type(): "fixed" | "dynamic"
-
-
+- Defined in src/pools/cluster/dynamic.ts:39
- get utilization(): number
-
-
+- Defined in src/pools/abstract-pool.ts:447
Pool maximum size.
+The pool maximum size.
Returns number
+Protected
minPool minimum size.
+The pool minimum size.
Returns number
+Private
readyReturns boolean
-Private
starting-- get starting(): boolean
--
-
-
Returns boolean
Inherited from FixedClusterPool.starting
--- Defined in src/pools/abstract-pool.ts:408
Protected
typePool type.
+The pool type.
If it is
'dynamic'
, it provides themax
property.Returns "fixed" | "dynamic"
Overrides FixedClusterPool.type
-- Defined in src/pools/cluster/dynamic.ts:38
Private
utilizationGets the approximate pool utilization.
+The approximate pool utilization.
Returns number
The pool utilization.
Inherited from FixedClusterPool.utilization
-- Defined in src/pools/abstract-pool.ts:428
Protected
worker-- get worker(): "cluster" | "thread"
+- get worker(): "thread" | "cluster"
-
-
-
+- Defined in src/pools/cluster/fixed.ts:135
+
Task Execution Hook
Gets the worker type.
+The worker type.
Returns "cluster" | "thread"
+Returns "thread" | "cluster"
Inherited from FixedClusterPool.worker
-- Defined in src/pools/cluster/fixed.ts:87
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.Inherited from FixedClusterPool.addTaskFunction
++- Defined in src/pools/abstract-pool.ts:804
Protected
after-- after
Task Execution Hook(worker, message): void
+- after
Task Execution Hook(workerNodeKey, message): void
-
-
-
-
@@ -378,28 +420,28 @@ Can be overridden.
-
-- Defined in src/pools/abstract-pool.ts:1041
+
+ Worker Node Setup
Hook executed after the worker task execution. Can be overridden.
@@ -365,8 +407,8 @@ Can be overridden.Parameters
worker: Worker
-The worker.
+workerNodeKey: number
+The worker node key.
Inherited from FixedClusterPool.afterTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:692
Worker Setup
+Protected
afterProtected
after-- after
Worker Setup(worker): void
+- after
Worker Node Setup(workerNodeKey): void
-
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:1354
Task Execution Hook
-
-- Defined in src/pools/abstract-pool.ts:1011
+
+ And Setup Dynamic Worker Node
-
-
Function that can be hooked up when a worker has been newly created and moved to the pool worker nodes. +
Method hooked up after a worker node has been newly created. Can be overridden.
Parameters
worker: Worker
-The newly created worker.
+workerNodeKey: number
+The newly created worker node key.
Returns void
Inherited from FixedClusterPool.afterWorkerSetup
+Inherited from FixedClusterPool.afterWorkerNodeSetup
-- Defined in src/pools/abstract-pool.ts:927
Protected
before@@ -425,49 +467,33 @@ Can be overridden.
Inherited from FixedClusterPool.beforeTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:671
Dynamic Pool Size
+Protected
checkProtected
create-- check
Dynamic Pool Size(min, max): void
+- create
And Setup Dynamic Worker Node(): number
-
-
-
-
-
Parameters
---
-
--
-
min: number
max: number
Returns void
Inherited from FixedClusterPool.checkDynamicPoolSize
--- Defined in src/pools/abstract-pool.ts:164
And Setup Dynamic Worker
-Protected
create-- create
And Setup Dynamic Worker(): Worker
--
-
-
-
-
-- Defined in src/pools/abstract-pool.ts:1258
+
+ And Setup Worker Node
Creates a new dynamic worker and sets it up completely in the pool worker nodes.
+Creates a new, completely set up dynamic worker node.
Returns Worker
New, completely set up dynamic worker.
+Returns number
New, completely set up dynamic worker node key.
Inherited from FixedClusterPool.createAndSetupDynamicWorker
+Inherited from FixedClusterPool.createAndSetupDynamicWorkerNode
-- Defined in src/pools/abstract-pool.ts:1010
And Setup Worker
+Protected
createProtected
create-- create
And Setup Worker(): Worker
+- create
And Setup Worker Node(): number
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:1214
Worker
+- Defined in src/pools/cluster/fixed.ts:125
+
+
- destroy(): Promise<void>
-
-
-
-- Defined in src/pools/abstract-pool.ts:948
+
+ Worker Node
Creates a new worker and sets it up completely in the pool worker nodes.
+Creates a new, completely set up worker node.
Returns Worker
New, completely set up worker.
+Returns number
New, completely set up worker node key.
Inherited from FixedClusterPool.createAndSetupWorker
+Inherited from FixedClusterPool.createAndSetupWorkerNode
-- Defined in src/pools/abstract-pool.ts:944
Protected
create@@ -480,68 +506,109 @@ Can be overridden.
Inherited from FixedClusterPool.createWorker
-- Defined in src/pools/cluster/fixed.ts:77
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
+Inherited from FixedClusterPool.deregisterWorkerMessageListener
++- Defined in src/pools/cluster/fixed.ts:117
destroy
Terminates every current worker in this pool.
+Terminates all workers in this pool.
Returns Promise<void>
Inherited from FixedClusterPool.destroy
-- Defined in src/pools/abstract-pool.ts:626
Worker
+Protected
destroyProtected
destroy-- destroy
Worker(worker): void
+- destroy
Worker Node(workerNodeKey): Promise<void>
-
-
-
-
-
-
+- Defined in src/pools/cluster/fixed.ts:63
- enable
Tasks Queue(enable, tasksQueueOptions?): void
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:563
Terminates the given worker.
+Terminates the worker node given its worker node key.
Parameters
worker: Worker
-A worker within
+workerNodes
.workerNodeKey: number
+The worker node key.
Returns void
+Returns Promise<void>
Inherited from FixedClusterPool.destroyWorker
+Inherited from FixedClusterPool.destroyWorkerNode
-- Defined in src/pools/cluster/fixed.ts:63
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
Inherited from FixedClusterPool.enableTasksQueue
-- Defined in src/pools/abstract-pool.ts:531
execute
-- execute(data?, name?): Promise<Response>
+- execute(data?, name?, transferList?): Promise<Response>
-
@@ -550,12 +617,17 @@ Can be overridden.
-
-
+
+-
+
+- Defined in src/pools/abstract-pool.ts:878
+
+
+
+
+
+
+
+
+
+
Busy
- internal
Busy(): boolean
-
-
+- Defined in src/pools/abstract-pool.ts:675
Main
+- Defined in src/pools/cluster/fixed.ts:58
+
+
+
+
+
+
+
+
+
+
+
+
To Worker
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.
@@ -563,20 +635,111 @@ Can be overridden.Inherited from FixedClusterPool.execute
-- Defined in src/pools/abstract-pool.ts:591
Worker Node As Not Ready
+Protected
flag+- flag
Worker Node As Not Ready(workerNodeKey): void
+-
+
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns void
Inherited from FixedClusterPool.flagWorkerNodeAsNotReady
++- Defined in src/pools/abstract-pool.ts:1643
Tasks Queue
+Protected
flush+- flush
Tasks Queue(workerNodeKey): void
+-
+
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns void
Inherited from FixedClusterPool.flushTasksQueue
++- Defined in src/pools/abstract-pool.ts:1690
Worker Info
+Protected
get+- get
Worker Info(workerNodeKey): WorkerInfo
+-
+
+
+
+
+
Gets the worker information given its worker node key.
+Parameters
++-
+
+
workerNodeKey: number
+The worker node key.
+Returns WorkerInfo
The worker information.
+ +Inherited from FixedClusterPool.getWorkerInfo
++- Defined in src/pools/abstract-pool.ts:1602
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.Inherited from FixedClusterPool.hasTaskFunction
++- Defined in src/pools/abstract-pool.ts:791
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.Inherited from FixedClusterPool.hasWorkerNodeBackPressure
++- Defined in src/pools/abstract-pool.ts:1648
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.
Inherited from FixedClusterPool.internalBusy
-- Defined in src/pools/abstract-pool.ts:582
Protected
is@@ -588,20 +751,170 @@ Can be overridden.
Inherited from FixedClusterPool.isMain
-- Defined in src/pools/cluster/fixed.ts:58
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.
+ +Inherited from FixedClusterPool.listTaskFunctionNames
++- Defined in src/pools/abstract-pool.ts:843
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
+Inherited from FixedClusterPool.registerOnceWorkerMessageListener
++- Defined in src/pools/cluster/fixed.ts:109
Worker Message Listener
+Protected
register+- register
Worker Message Listener<Message>(workerNodeKey, listener): void
+-
+
+
+
+
+
+
+
Registers 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
+Inherited from FixedClusterPool.registerWorkerMessageListener
++- Defined in src/pools/cluster/fixed.ts:101
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.Inherited from FixedClusterPool.removeTaskFunction
++- Defined in src/pools/abstract-pool.ts:827
Kill Message To Worker
+Protected
send+- send
Kill Message To Worker(workerNodeKey): Promise<void>
+-
+
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns Promise<void>
Inherited from FixedClusterPool.sendKillMessageToWorker
++- Defined in src/pools/abstract-pool.ts:959
Startup Message To Worker
+Protected
send+- send
Startup Message To Worker(workerNodeKey): void
+-
+
+
+
+
+
Sends the startup message to worker given its worker node key.
+Parameters
++-
+
+
workerNodeKey: number
+The worker node key.
+Returns void
+Inherited from FixedClusterPool.sendStartupMessageToWorker
++- Defined in src/pools/cluster/fixed.ts:94
Protected
send-- send
To Worker(worker, message): void
+- send
To Worker(workerNodeKey, message): void
-
-
-
-
-
@@ -613,27 +926,48 @@ Can be overridden.
+- Defined in src/pools/cluster/fixed.ts:83
+
+
- set
Tasks Queue Options(tasksQueueOptions): void
-
-
-
+- Defined in src/pools/abstract-pool.ts:577
+- Defined in src/pools/abstract-pool.ts:530
+- Defined in src/pools/abstract-pool.ts:549
Hook
-
-
+
+
+
-
-
\ No newline at end of file
+
+
\ No newline at end of file
Sends a message to the given worker.
+Sends a message to worker given its worker node key.
Parameters
worker: Worker
-The worker which should receive the message.
+workerNodeKey: number
+The worker node key.
Inherited from FixedClusterPool.sendToWorker
-- Defined in src/pools/cluster/fixed.ts:72
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.Inherited from FixedClusterPool.setDefaultTaskFunction
++- Defined in src/pools/abstract-pool.ts:856
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
Inherited from FixedClusterPool.setTasksQueueOptions
-- Defined in src/pools/abstract-pool.ts:543
set Worker Choice Strategy
@@ -658,7 +992,7 @@ Can be overridden.
Inherited from FixedClusterPool.setWorkerChoiceStrategy
-- Defined in src/pools/abstract-pool.ts:501
set Worker Choice Strategy Options
@@ -678,7 +1012,7 @@ Can be overridden.
Inherited from FixedClusterPool.setWorkerChoiceStrategyOptions
-- Defined in src/pools/abstract-pool.ts:520
Protected
setup@@ -691,40 +1025,41 @@ Can be overridden.
Inherited from FixedClusterPool.setupHook
-- Defined in src/pools/cluster/fixed.ts:53
Listener
-Protected
worker-- worker
Listener(): ((message) => void)
+- Defined in src/pools/cluster/fixed.ts:53
start
++- start(): void
-
-
-
+
+- start
+- worker
Message Listener
-
This function 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
+Inherited from FixedClusterPool.start
++- Defined in src/pools/abstract-pool.ts:932
Message Listener
+Protected
worker+- worker
Message Listener(message): void
-
-
-
-
-
+ - Defined in src/pools/abstract-pool.ts:1516
This function 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
Inherited from FixedClusterPool.workerListener
+Inherited from FixedClusterPool.workerMessageListener
-- Defined in src/pools/abstract-pool.ts:1041
-
+Settings
Settings
Member Visibility
Generated using TypeDoc
Generated using TypeDoc