X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=docs%2Fclasses%2FDynamicThreadPool.html;h=66d9f45a8f6237d9b94258e27bce62d4bc7e8bd9;hb=6c4fa3e1bd11a23fd83b8492ad941a323853de06;hp=9d5f653e0594943bb10be5cb97d960719ebe8fa3;hpb=969223ea18802a84dfea369e254332e11bf8e419;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index 9d5f653e..66d9f45a 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,13 +1,13 @@ -
Optional
Readonly
emitterGenerated using TypeDoc
Generated using TypeDoc
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:
'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.'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
maxProtected
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
workerReadonly
Internal
workerAccessors
Protected
full@@ -267,7 +274,7 @@ When the maximum number of threads is reached and workers are busy, an event is
info
@@ -279,7 +286,7 @@ When the maximum number of threads is reached and workers are busy, an event is
Protected
max@@ -291,7 +298,7 @@ When the maximum number of threads is reached and workers are busy, an event is
Protected
min@@ -303,7 +310,7 @@ When the maximum number of threads is reached and workers are busy, an event is
Private
ready@@ -315,7 +322,7 @@ When the maximum number of threads is reached and workers are busy, an event is
Protected
type@@ -328,7 +335,7 @@ When the maximum number of threads is reached and workers are busy, an event is
Private
utilization@@ -341,7 +348,7 @@ When the maximum number of threads is reached and workers are busy, an event is
Protected
worker@@ -353,9 +360,40 @@ When the maximum number of threads is reached and workers are busy, an event is
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@@ -381,7 +419,7 @@ Can be overridden.
Protected
after@@ -402,7 +440,7 @@ Can be overridden.
Protected
before@@ -428,23 +466,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@@ -457,7 +479,7 @@ Can be overridden.
Protected
create@@ -470,7 +492,7 @@ Can be overridden.
Protected
create@@ -483,7 +505,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
@@ -495,7 +558,7 @@ Can be overridden.
Protected
destroy@@ -515,7 +578,7 @@ Can be overridden.
enable Tasks Queue
@@ -540,7 +603,7 @@ Can be overridden.
execute
@@ -571,7 +634,7 @@ Can be overridden.
Protected
flush@@ -585,11 +648,11 @@ Can be overridden.
Returns void
Protected
get-- get
Worker Info(workerNodeKey): undefined | WorkerInfo
+- get
Worker Info(workerNodeKey): WorkerInfo
-
@@ -601,12 +664,33 @@ Can be overridden.
Gets the worker information given its worker node key.
The worker node key.
Returns undefined | WorkerInfo
The worker information.
+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
@@ -627,7 +711,7 @@ Can be overridden.
Protected
internal@@ -640,7 +724,7 @@ Can be overridden.
Protected
is@@ -652,20 +736,61 @@ Can be overridden.
list Task Functions
+list Task Function Names
-- list
Task Functions(): string[]
+- 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@@ -706,23 +831,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.Protected
send-- send
Kill Message To Worker(workerNodeKey, workerId): Promise<void>
+- send
Kill Message To Worker(workerNodeKey): Promise<void>
-
-
-
--
-
+
Parameters
workerNodeKey: number
workerId: number
workerNodeKey: number
Returns Promise<void>
Protected
send@@ -742,7 +886,7 @@ Can be overridden.
Protected
send@@ -772,7 +916,28 @@ 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
@@ -792,7 +957,7 @@ Can be overridden.
set Worker Choice Strategy
@@ -817,7 +982,7 @@ Can be overridden.
set Worker Choice Strategy Options
@@ -837,7 +1002,7 @@ Can be overridden.
Protected
setup@@ -850,40 +1015,41 @@ Can be overridden.
Listener
-Protected
worker-- worker
Listener(): ((message) => void)
+- Defined in src/pools/abstract-pool.ts:987
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:1496
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