X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FFixedClusterPool.html;h=f9dfcb3931ff6e9456eb709d474b12fb2b9b622d;hb=b2ec8632edaea1f4ee24a532e61ca6e5619b7bfb;hp=dd35f98d01c694769753bcbb34b308f4498ce8dc;hpb=2624da4d8f724e8bc0b655cddfc6ba5ae9a4d053;p=poolifier.git diff --git a/docs/classes/FixedClusterPool.html b/docs/classes/FixedClusterPool.html index dd35f98d..f9dfcb39 100644 --- a/docs/classes/FixedClusterPool.html +++ b/docs/classes/FixedClusterPool.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 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
file
+Protected
Optional
Readonly
maxDynamic pool maximum size property placeholder.
+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@@ -241,7 +270,7 @@
info
@@ -253,88 +282,118 @@
Size
-Protected
max+- get maxSize(): number
-
-
+- Defined in src/pools/abstract-pool.ts:486
+
Pool maximum size.
+The pool maximum size.
Returns number
- Size
-Protected
min+- get minSize(): number
-
-
-- Defined in src/pools/abstract-pool.ts:479
+
+
Pool minimum size.
+The pool minimum size.
Returns number
- Time
+Private
runPrivate
ready-- get runTime(): number
+- get ready(): boolean
-
-
-- Defined in src/pools/abstract-pool.ts:431
- get type(): "fixed" | "dynamic"
-
-
- Defined in src/pools/cluster/fixed.ts:130
- get utilization(): number
-
-
- Defined in src/pools/abstract-pool.ts:448
Gets the pool run time.
+The pool readiness boolean status.
Returns number
The pool run time in milliseconds.
- +Returns boolean
+Protected
typePool type.
+The pool type.
If it is
'dynamic'
, it provides themax
property.Returns "fixed" | "dynamic"
+Private
utilizationGets the approximate pool utilization.
+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
-
-
-
-
@@ -356,28 +415,28 @@ Can be overridden.
-
-- Defined in src/pools/abstract-pool.ts:1043
+
+ Worker Node Setup
Hook executed after the worker task execution. Can be overridden.
@@ -343,8 +402,8 @@ Can be overridden.Parameters
worker: Worker
-The worker.
+workerNodeKey: number
+The worker node key.
Worker Setup
+Protected
afterProtected
after-- after
Worker Setup(worker): void
+- after
Worker Node Setup(workerNodeKey): void
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:1356
Task Execution Hook
-
-- Defined in src/pools/abstract-pool.ts:1013
+
+ 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
Protected
before@@ -403,33 +462,33 @@ Can be overridden.
And Setup Dynamic Worker
+Protected
createProtected
create-- create
And Setup Dynamic Worker(): Worker
+- create
And Setup Dynamic Worker Node(): number
-
-
-
-- Defined in src/pools/abstract-pool.ts:1260
+
+ 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:1216
Worker
+- Defined in src/pools/cluster/fixed.ts:125
+
+
- destroy(): Promise<void>
-
-
-- Defined in src/pools/abstract-pool.ts:949
+
+ 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@@ -442,68 +501,109 @@ 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
Terminates 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:564
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>
-
@@ -512,12 +612,17 @@ Can be overridden.
-
-
+
+-
+
+- Defined in src/pools/abstract-pool.ts:879
+
+
+
+
+
+
+
+
+
+
Busy
- internal
Busy(): boolean
-
-
- Defined in src/pools/abstract-pool.ts:676
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.
@@ -525,20 +630,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
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@@ -550,20 +746,170 @@ 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
+ 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
+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>
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
-
-
-
-
-
@@ -575,27 +921,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:578
+- Defined in src/pools/abstract-pool.ts:531
+- Defined in src/pools/abstract-pool.ts:550
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.
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
@@ -620,7 +987,7 @@ Can be overridden.
set Worker Choice Strategy Options
@@ -640,7 +1007,7 @@ Can be overridden.
Protected
setup@@ -653,40 +1020,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 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
+ Message Listener
+Protected
worker+- worker
Message Listener(message): void
-
-
-
-
+ - Defined in src/pools/abstract-pool.ts:1518
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
-
+Settings
Settings
Member Visibility
Generated using TypeDoc
Generated using TypeDoc