X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicClusterPool.html;h=1767983b04add9aa7d5360d287e04c72716bb93a;hb=34aa5747c72ab1952481eecf2932361fd8b49d01;hp=c5d7bc80ca36a5d48a0ba4e739791d0ef671c34a;hpb=4f487526a63c873d168386250b40ad8103c5a4d8;p=poolifier.git diff --git a/docs/classes/DynamicClusterPool.html b/docs/classes/DynamicClusterPool.html index c5d7bc80..1767983b 100644 --- a/docs/classes/DynamicClusterPool.html +++ b/docs/classes/DynamicClusterPool.html @@ -1,13 +1,13 @@ -
Type of data sent to the worker. This can only be serializable data.
+Type of data sent to the worker. This can only be structured-cloneable data.
Response = unknown
-Type of execution response. This can only be serializable data.
+Type of execution response. This can only be structured-cloneable data.
-
+Index
Index
Constructors
-Properties
-Accessors
-Methods
-Constructors
constructor
+constructor
Properties
-Optional
Readonly
emitterEmitter 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 full.'busy'
: Emitted when the pool is busy.'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 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
workerWorker choice strategy context referencing a worker choice algorithm implementation.
-Default to a round robin algorithm.
Nodes
-Readonly
worker Nodes
+Readonly
Internal
workerPool worker nodes.
Accessors
Protected
full@@ -255,7 +275,7 @@ When the maximum number of workers is reached and workers are busy, an event is
info
@@ -267,62 +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 type(): "fixed" | "dynamic"
-
-
- Defined in src/pools/cluster/dynamic.ts:39
+
+
Pool maximum size.
+The pool maximum size.
Returns number
+Protected
minPool minimum size.
+The pool minimum size.
Returns number
+
+Private
ready+- get ready(): boolean
+-
+
+
The pool readiness boolean status.
+Returns boolean
+Protected
typePool type.
+The pool type.
If it is
'dynamic'
, it provides themax
property.Returns "fixed" | "dynamic"
+
+Private
utilization+- get utilization(): number
+-
+
+
The approximate pool utilization.
+Returns number
The pool utilization.
+ +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"
+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-- after
Task Execution Hook(worker, message): void
+- after
Task Execution Hook(workerNodeKey, message): void
-
-
-
-
-
@@ -344,32 +420,32 @@ Can be overridden.
-
-- Defined in src/pools/abstract-pool.ts:1041
+
+ Worker Node Setup
Hook executed after the worker task execution. Can be overridden.
@@ -331,12 +407,12 @@ Can be overridden.Parameters
worker: Worker
-The worker.
+workerNodeKey: number
+The worker node key.
message: MessageValue<Response, Worker | MessagePort>
+message: MessageValue<Response, unknown>
The received message.
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.
-Can be used to update the
+maxListeners
or binding themain-worker
<->worker
connection if not bind by default.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
Protected
before-- before
Task Execution Hook(workerNodeKey): void
+- before
Task Execution Hook(workerNodeKey, task): void
-
+
+-
+
Hook executed before the worker task execution. Can be overridden.
@@ -381,112 +457,158 @@ Can be overridden.workerNodeKey: number
The worker node key.
task: Task<Data>
+The task to execute.
+Returns void
Worker Node
+Protected
chooseProtected
create-- choose
Worker Node(): number
+- create
And Setup Dynamic Worker Node(): number
-
-
-
-- Defined in src/pools/abstract-pool.ts:1258
+
+ And Setup Worker Node
Chooses a worker node for the next task.
-The default worker choice strategy uses a round robin algorithm to distribute the load.
+Creates a new, completely set up dynamic worker node.
Returns number
The worker node key
+Returns number
New, completely set up dynamic worker node key.
- 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
- create
Worker(): 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.
+Protected
createReturns a newly created worker.
+Creates a new worker.
Returns Worker
+Returns Worker
Newly created worker.
+ + 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
Shutdowns every current worker in this pool.
+Terminates all workers in this pool.
Returns Promise<void>
- 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
+- Defined in src/pools/cluster/fixed.ts:101
+
+
+
+
+
+
To Worker
+
\ No newline at end of file
Shutdowns 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>
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>
-
@@ -495,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
+
+
+
+
Worker Message Listener
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 serializable 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.
@@ -508,16 +635,111 @@ Can be overridden. Worker Node As Not Ready
+Protected
flag+- flag
Worker Node As Not Ready(workerNodeKey): void
+-
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns void
Tasks Queue
+Protected
flush+- flush
Tasks Queue(workerNodeKey): void
+-
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns void
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.
+ +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
internalReturns boolean
Protected
is@@ -529,13 +751,67 @@ Can be overridden.
Inherited from FixedClusterPool.isMain
-- Defined in src/pools/cluster/fixed.ts:68
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
Protected
register-- register
Worker Message Listener<Message>(worker, listener): void
+- register
Worker Message Listener<Message>(workerNodeKey, listener): void
-
-
-
-
-
@@ -564,30 +840,85 @@ Can be overridden.
-
-
+
Registers a listener callback on the given worker.
+Registers a listener callback on the worker given its worker node key.
Type Parameters
@@ -546,8 +822,8 @@ Can be overridden.Parameters
worker: Worker
-The worker which should register a listener.
+workerNodeKey: number
+The worker node key.
Parameters
message: MessageValue<Message, Worker | MessagePort>
message: MessageValue<Message, unknown>
Returns void
Returns void
Inherited from FixedClusterPool.registerWorkerMessageListener
-- Defined in src/pools/cluster/fixed.ts:84
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
-
-
-
-
-
-
@@ -595,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
- setup
Hook(): void
-
-
-
-
+
+
+- start
+- worker
Message Listener
-
+
-
-
\ 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.
message: MessageValue<Data, Worker | MessagePort>
+message: MessageValue<Data, unknown>
The message.
Inherited from FixedClusterPool.sendToWorker
-- Defined in src/pools/cluster/fixed.ts:79
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:340
set Worker Choice Strategy
@@ -627,7 +979,7 @@ Can be overridden.-
-
@@ -640,7 +992,7 @@ Can be overridden.
Parameters
workerChoiceStrategy: "ROUND_ROBIN" | "LEAST_USED" | "LEAST_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN" | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"
+workerChoiceStrategy: "ROUND_ROBIN" | "LEAST_USED" | "LEAST_BUSY" | "LEAST_ELU" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN" | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"
The worker choice strategy.
Inherited from FixedClusterPool.setWorkerChoiceStrategy
-- Defined in src/pools/abstract-pool.ts:285
set Worker Choice Strategy Options
@@ -660,53 +1012,54 @@ Can be overridden.
Inherited from FixedClusterPool.setWorkerChoiceStrategyOptions
-- Defined in src/pools/abstract-pool.ts:317
Protected
setupSetup hook to execute code before worker node are created in the abstract constructor. -Can be overridden
+Setup hook to execute code before worker nodes are created in the abstract constructor. +Can be overridden.
Returns void
Inherited from FixedClusterPool.setupHook
-- Defined in src/pools/cluster/fixed.ts:63
Listener
-Protected
worker-- worker
Listener(): ((message) => void)
+- Defined in src/pools/cluster/fixed.ts:53
start
++- start(): void
-
-
-
+
+ - Defined in src/pools/abstract-pool.ts:1516
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
-
-
-
-
-
+
-
This function is the listener registered for each worker message.
+This method is the message listener registered on each worker.
Parameters
message: MessageValue<Response, Worker | MessagePort>
Returns void
The listener function to execute when a message is received from a worker.
- - +message: MessageValue<Response, unknown>
Returns void
Inherited from FixedClusterPool.workerListener
+Inherited from FixedClusterPool.workerMessageListener
-- Defined in src/pools/abstract-pool.ts:653
-
+Settings
Settings
Member Visibility
Generated using TypeDoc
Generated using TypeDoc