X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=docs%2Fclasses%2FDynamicClusterPool.html;h=0c403e1718a1a44878d560d15c650ccef0054297;hb=0bb3df76aeab8a2af9e99ccf91d9e9cc5e751674;hp=20fa33dc6a187ee41c907235b4a735f09d74b5b9;hpb=6be0ab6d5c78c8e91cc4668d3d03db95f15cbfab;p=poolifier.git diff --git a/docs/classes/DynamicClusterPool.html b/docs/classes/DynamicClusterPool.html index 20fa33dc..0c403e17 100644 --- a/docs/classes/DynamicClusterPool.html +++ b/docs/classes/DynamicClusterPool.html @@ -1,4 +1,4 @@ -
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.
@@ -59,7 +59,7 @@ When the maximum number of workers is reached and workers are busy, an event isemitter?
file Path
-max
+max
number Of Workers
opts
promise Response Map
@@ -71,26 +71,35 @@ When the maximum number of workers is reached and workers are busy, an event is
busy
full
info
-max Size
+max Size
min Size
+ready
type
+utilization
worker
after Task Execution Hook
-after Worker Setup
+after Worker Node Setup
before Task Execution Hook
-create And Setup Dynamic Worker
-create And Setup Worker
+check Dynamic Pool Size
+create And Setup Dynamic Worker Node
+create And Setup Worker Node
create Worker
destroy
-destroy Worker
+destroy Worker Node
enable Tasks Queue
execute
+flush Tasks Queue
+get Worker Info
+has Worker Node Back Pressure
internal Busy
is Main
+list Task Functions
register Worker Message Listener
+send Kill Message To Worker
+send Startup Message To Worker
send To Worker
set Tasks Queue Options
set Worker Choice Strategy
@@ -141,7 +150,7 @@ When the maximum number of workers is reached and workers are busy, an event is
+- Defined in src/pools/cluster/dynamic.ts:27
@@ -150,16 +159,19 @@ When the maximum number of workers is reached and workers are busy, an event is
+- Defined in src/pools/abstract-pool.ts:66
Path
file Path: string
@@ -168,15 +180,16 @@ When the maximum number of workers is reached and workers are busy, an event is
-
+- Defined in src/pools/abstract-pool.ts:115
+
max: number
+- Defined in src/pools/cluster/dynamic.ts:29
Of Workers
number Of Workers: number
@@ -185,7 +198,7 @@ When the maximum number of workers is reached and workers are busy, an event is
+- Defined in src/pools/abstract-pool.ts:114
opts: ClusterPoolOptions = {}
@@ -194,11 +207,11 @@ When the maximum number of workers is reached and workers are busy, an event is
+- Defined in src/pools/cluster/fixed.ts:47
promise Response Map: Map<string, PromiseResponseWrapper<Worker, Response>> = ...
-promise Response Map: Map<string, PromiseResponseWrapper<Response>> = ...
+
@@ -208,7 +221,7 @@ When the maximum number of workers is reached and workers are busy, an event is
+- Defined in src/pools/abstract-pool.ts:76
Choice Strategy Context
worker Choice Strategy Context: WorkerChoiceStrategyContext<Worker, Data, Response>
@@ -217,16 +230,16 @@ When the maximum number of workers is reached and workers are busy, an event is
+- Defined in src/pools/abstract-pool.ts:82
-worker Nodes: WorkerNode<Worker, Data>[] = []
+worker Nodes: IWorkerNode<Worker, Data>[] = []
+- Defined in src/pools/abstract-pool.ts:63
@@ -241,7 +254,7 @@ When the maximum number of workers is reached and workers are busy, an event is
+- Defined in src/pools/cluster/dynamic.ts:43
+- Defined in src/pools/abstract-pool.ts:682
-
+- Defined in src/pools/abstract-pool.ts:354
+
Properties
Methods
Properties
Emitter on which events can be listened to.
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 at least one task.'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
worker Nodes
+Readonly
Internal
workerPool worker nodes.
Accessors
Protected
full@@ -254,7 +267,7 @@ When the maximum number of workers is reached and workers are busy, an event is
info
@@ -266,62 +279,87 @@ 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:555
Size
- get minSize(): number
-
-
- Defined in src/pools/abstract-pool.ts:548
+
+
- get type(): "fixed" | "dynamic"
-
-
- Defined in src/pools/cluster/dynamic.ts:38
+
+
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:115
Task Execution Hook
Gets the worker type.
+The worker type.
Returns "cluster" | "thread"
+Returns "thread" | "cluster"
+Methods
Protected
after-- after
Task Execution Hook(worker, message): void
+- after
Task Execution Hook(workerNodeKey, message): void
-
-
-
-
-
@@ -343,28 +381,28 @@ Can be overridden.
-
-- Defined in src/pools/abstract-pool.ts:879
+
+ Worker Node Setup
Hook executed after the worker task execution. Can be overridden.
@@ -330,12 +368,12 @@ Can be overridden.Parameters
worker: Worker
-The worker.
+workerNodeKey: number
+The worker node key.
message: MessageValue<Response, unknown, 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:1151
Task Execution Hook
-
-- Defined in src/pools/abstract-pool.ts:849
+
+
+
+ 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@@ -390,33 +428,49 @@ Can be overridden.
And Setup Dynamic Worker
+Protected
create Dynamic Pool Size
+Protected
check+- check
Dynamic Pool Size(min, max): void
+-
+
+
+
Parameters
++-
+
+-
+
min: number
max: number
Returns void
Protected
create-- create
And Setup Dynamic Worker(): Worker
+- create
And Setup Dynamic Worker Node(): number
-
-
-
-- Defined in src/pools/abstract-pool.ts:1094
+
+ 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.
- And Setup Worker
+Protected
createProtected
create-- create
And Setup Worker(): Worker
+- create
And Setup Worker Node(): number
-
-
-- Defined in src/pools/abstract-pool.ts:1050
Worker
+- Defined in src/pools/cluster/fixed.ts:105
- destroy(): Promise<void>
-
-
-- Defined in src/pools/abstract-pool.ts:794
+
+ 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
create@@ -429,68 +483,68 @@ Can be overridden.
destroy
Terminate 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:636
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>
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>
-
@@ -499,12 +553,17 @@ Can be overridden.
-
-
+
+-
+
+- Defined in src/pools/abstract-pool.ts:732
+
+
+
+
+
+
Busy
- internal
Busy(): boolean
-
-
- Defined in src/pools/abstract-pool.ts:698
Main
+- Defined in src/pools/cluster/fixed.ts:58
+
+
Worker Message Listener
+- Defined in src/pools/cluster/fixed.ts:97
+
+
+
+
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 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.
@@ -512,20 +571,76 @@ Can be overridden. Tasks Queue
+Protected
flush+- flush
Tasks Queue(workerNodeKey): void
+-
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns void
Worker Info
+Protected
get+- get
Worker Info(workerNodeKey): undefined | WorkerInfo
+-
+
+
+
+
Gets the worker information given its worker node key.
+Parameters
++-
+
+
workerNodeKey: number
+The worker node key.
+Returns undefined | WorkerInfo
The worker information.
+ +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@@ -537,13 +652,26 @@ Can be overridden.
list Task Functions
++- list
Task Functions(): string[]
+-
+
+
Lists the names of task function available in this pool.
+Returns string[]
The names of task function available in this pool.
+ +Protected
register-- register
Worker Message Listener<Message>(worker, listener): void
+- register
Worker Message Listener<Message>(workerNodeKey, listener): void
-
-
-
-
-
@@ -572,30 +700,66 @@ 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
@@ -554,8 +682,8 @@ Can be overridden.Parameters
worker: Worker
-The worker which should register a listener.
+workerNodeKey: number
+The worker node key.
Parameters
message: MessageValue<Message, unknown, Worker | MessagePort>
message: MessageValue<Message, unknown>
Returns void
Returns void
Kill Message To Worker
+Protected
send+- send
Kill Message To Worker(workerNodeKey, workerId): Promise<void>
+-
+
+
+
Parameters
++-
+
+-
+
workerNodeKey: number
workerId: number
Returns Promise<void>
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
+Protected
send-- send
To Worker(worker, message): void
+- send
To Worker(workerNodeKey, message): void
-
-
-
-
-
-
@@ -603,27 +767,27 @@ Can be overridden.
+- Defined in src/pools/cluster/fixed.ts:81
- set
Tasks Queue Options(tasksQueueOptions): void
-
-
-
+- Defined in src/pools/abstract-pool.ts:648
+- Defined in src/pools/abstract-pool.ts:603
+- Defined in src/pools/abstract-pool.ts:622
Hook
- setup
Hook(): void
-
-
- Defined in src/pools/cluster/fixed.ts:53
Listener
- worker
Listener(): ((message) => void)
-
-
- (message): void
-
-
-
-
+
+ - Defined in src/pools/abstract-pool.ts:1302
@@ -732,7 +896,7 @@ Can be overridden
- constructor
- emitter
- file
Path
-- max
+- max
- number
Of Workers
- opts
- promise
Response Map
@@ -741,23 +905,32 @@ Can be overridden
- busy
- full
- info
-- max
Size
+- max
Size
- min
Size
+- ready
- type
+- utilization
- worker
- after
Task Execution Hook
-- after
Worker Setup
+- after
Worker Node Setup
- before
Task Execution Hook
-- create
And Setup Dynamic Worker
-- create
And Setup Worker
+- check
Dynamic Pool Size
+- create
And Setup Dynamic Worker Node
+- create
And Setup Worker Node
- create
Worker
- destroy
-- destroy
Worker
+- destroy
Worker Node
- enable
Tasks Queue
- execute
+- flush
Tasks Queue
+- get
Worker Info
+- has
Worker Node Back Pressure
- internal
Busy
- is
Main
+- list
Task Functions
- register
Worker Message Listener
+- send
Kill Message To Worker
+- send
Startup Message To Worker
- send
To Worker
- set
Tasks Queue Options
- set
Worker Choice Strategy
@@ -765,18 +938,18 @@ Can be overridden
- setup
Hook
- worker
Listener
-
+- Worker
Types
+- available
Parallelism
\ 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, unknown, Worker | MessagePort>
+message: MessageValue<Data, unknown>
The message.
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
@@ -648,7 +812,7 @@ Can be overridden.
set Worker Choice Strategy Options
@@ -668,26 +832,26 @@ Can be overridden.
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
+Protected
workerThis function is the listener registered for each worker message.
+This method is the listener registered for each worker message.
Returns ((message) => void)
The listener function to execute when a message is received from a worker.
@@ -696,20 +860,20 @@ Can be overriddenThis function is the listener registered for each worker message.
+This method is the listener registered for each worker message.
Parameters
message: MessageValue<Response, unknown, Worker | MessagePort>
message: MessageValue<Response, unknown>
Returns void
The listener function to execute when a message is received from a worker.
Generated using TypeDoc