X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicClusterPool.html;h=e58245ddb04ce54782236ec11b5eedbc2a8ece25;hb=40baeb4e66efa6646d3221029cd012fb7bda8955;hp=c6b1cb310994458672bcec52a5aae2ddb859b682;hpb=4101537483d2883af1f76ef2366bb7e92d0d3c4e;p=poolifier.git diff --git a/docs/classes/DynamicClusterPool.html b/docs/classes/DynamicClusterPool.html index c6b1cb31..e58245dd 100644 --- a/docs/classes/DynamicClusterPool.html +++ b/docs/classes/DynamicClusterPool.html @@ -6,7 +6,7 @@
A cluster pool with a dynamic number of workers, but a guaranteed minimum number of workers.
This cluster pool creates new workers when the others are busy, up to the maximum number of workers. -When the maximum number of workers is reached, an event is emitted. If you want to listen to this event, use the pool's
+When the maximum number of workers is reached and workers are busy, an event is emitted. If you want to listen to this event, use the pool'semitter
.emitter
.Author
Christopher Quadflieg
@@ -42,7 +42,7 @@ When the maximum number of workers is reached, an event is emitted. If you want@@ -56,42 +56,36 @@ When the maximum number of workers is reached, an event is emitted. If you wantemitter?
file Path
-max
-next Message Id
+max
number Of Workers
opts
-promise Map
+promise Response Map
worker Choice Strategy Context
-workers
-workers Tasks Usage
+worker Nodes
Properties
Accessors
Methods
-Returns DynamicClusterPool<Data, Response>
+Properties
Inherit Doc
Path
-Readonly
fileReadonly
maxInherit Doc
Inherited from FixedClusterPool.max
--- Defined in src/pools/cluster/dynamic.ts:30
Message Id
-Protected
nextId of the next message.
+Maximum number of workers that can be created by this pool.
Inherited from FixedClusterPool.nextMessageId
-- Defined in src/pools/abstract-pool.ts:61
Of Workers
-Readonly
numberNumber of workers that this pool should manage.
+Inherited from FixedClusterPool.numberOfWorkers
-- Defined in src/pools/abstract-pool.ts:82
-Readonly
optsOptions for this fixed cluster pool.
+Inherited from FixedClusterPool.opts
-- Defined in src/pools/cluster/fixed.ts:53
Map
-Protected
promiseThe promise map.
+ Response Map
+Protected
promiseThe execution response promise map.
-
-
+
+
-key
: This is the message Id of each submitted task.value
: An object that contains the worker, the resolve function and the reject function.key
: The message id of each submitted task.value
: An object that contains the worker, the execution response promise resolve and reject callbacks.When we receive a message from the worker we get a map entry and resolve/reject the promise based on the message.
+When we receive a message from the worker, we get a map entry with the promise resolve/reject bound to the message id.
Inherited from FixedClusterPool.promiseMap
+Inherited from FixedClusterPool.promiseResponseMap
-- Defined in src/pools/abstract-pool.ts:53
Protected
workerWorker choice strategy instance implementing the worker choice algorithm.
-Default to a strategy implementing a round robin algorithm.
+Worker choice strategy context referencing a worker choice algorithm implementation.
+Default to a round robin algorithm.
Inherited from FixedClusterPool.workerChoiceStrategyContext
-- Defined in src/pools/abstract-pool.ts:68
-Readonly
workersInherit Doc
Inherited from FixedClusterPool.workers
--- Defined in src/pools/abstract-pool.ts:31
Tasks Usage
-Readonly
workers Nodes
+Readonly
workerInherit Doc
Inherited from FixedClusterPool.workersTasksUsage
+Inherited from FixedClusterPool.workerNodes
-- Defined in src/pools/abstract-pool.ts:34
Accessors
Returns boolean
Overrides FixedClusterPool.busy
-- Defined in src/pools/cluster/dynamic.ts:43
number Of Running Tasks
--- get numberOfRunningTasks(): number
+- Defined in src/pools/cluster/dynamic.ts:48
full
++- get full(): boolean
-
+
+
Inherit Doc
Returns boolean
Overrides FixedClusterPool.full
++- Defined in src/pools/cluster/dynamic.ts:43
Of Queued Tasks
+Private
number+- get numberOfQueuedTasks(): number
+-
+
+
+
Number of tasks queued in the pool.
+Returns number
Inherited from FixedClusterPool.numberOfQueuedTasks
++- Defined in src/pools/abstract-pool.ts:166
Of Running Tasks
+Private
number+- get numberOfRunningTasks(): number
+-
+
Number of tasks running in the pool.
+Returns number
Inherited from FixedClusterPool.numberOfRunningTasks
-- Defined in src/pools/abstract-pool.ts:154
type
@@ -252,32 +257,32 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns PoolType
Overrides FixedClusterPool.type
-- Defined in src/pools/cluster/dynamic.ts:38
Methods
- Promise Worker Response Hook
+Protected
afterProtected
after-- after
Promise Worker Response Hook(message: MessageValue<Response, unknown>, promise: PromiseWorkerResponseWrapper<Worker, Response>): void
+- after
Task Execution Hook(worker: Worker, message: MessageValue<Response, unknown>): void
-
-
-
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:304
Worker Setup
-
-- Defined in src/pools/cluster/fixed.ts:93
+
+ Task Execution Hook
Hook executed after the worker task promise resolution. +
Hook executed after the worker task execution. Can be overridden.
Parameters
message: MessageValue<Response, unknown>
-The received message.
+worker: Worker
+The worker.
promise: PromiseWorkerResponseWrapper<Worker, Response>
-The Promise response.
+message: MessageValue<Response, unknown>
+The received message.
Returns void
Inherited from FixedClusterPool.afterPromiseWorkerResponseHook
+Inherited from FixedClusterPool.afterTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:263
Protected
after@@ -293,53 +298,53 @@ Can be overridden.
Returns void
Inherited from FixedClusterPool.afterWorkerSetup
-- Defined in src/pools/cluster/fixed.ts:93
Promise Worker Response Hook
+Protected
beforeProtected
before-- before
Promise Worker Response Hook(worker: Worker): void
+- before
Task Execution Hook(workerNodeKey: number): void
-
-
-
-
-
-
-- Defined in src/pools/abstract-pool.ts:293
+
+ Worker Node
+- Defined in src/pools/abstract-pool.ts:189
Hook
+- Defined in src/pools/cluster/fixed.ts:59
Listener
- worker
Listener(): ((message: MessageValue<Response, unknown>) => void)
-
-
@@ -619,7 +524,7 @@ Can be overridden.
- (message: MessageValue<Response, unknown>): void
-
-
@@ -631,7 +536,7 @@ Can be overridden.
+ - Defined in src/pools/abstract-pool.ts:422
Hook executed before the worker task promise resolution. +
Hook executed before the worker task execution. Can be overridden.
Parameters
worker: Worker
-The worker.
+workerNodeKey: number
+The worker node key.
Returns void
Inherited from FixedClusterPool.beforePromiseWorkerResponseHook
+Inherited from FixedClusterPool.beforeTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:252
Worker
+Protected
chooseProtected
choose-- choose
Worker(): Worker
+- choose
Worker Node(): [number, WorkerNode<Worker, Data>]
-
-
-
-
+
+- Defined in src/pools/abstract-pool.ts:337
And Setup Worker
- create
And Setup Worker(): Worker
-
-
+- Defined in src/pools/abstract-pool.ts:399
Worker
+- Defined in src/pools/cluster/fixed.ts:88
+- Defined in src/pools/abstract-pool.ts:256
+- Defined in src/pools/cluster/fixed.ts:69
-
-- Defined in src/pools/abstract-pool.ts:228
+
+
-
-
-
-
-
-
-
-
-
-
-
-- Defined in src/pools/abstract-pool.ts:221
+
+ Busy
+- Defined in src/pools/abstract-pool.ts:216
Main
+- Defined in src/pools/cluster/fixed.ts:64
-
-
+- Defined in src/pools/cluster/fixed.ts:80
To Worker
+- Defined in src/pools/cluster/fixed.ts:75
+
Chooses a worker for the next task.
-The default implementation uses a round robin algorithm to distribute the load.
+Chooses a worker node for the next task.
+The default uses a round robin algorithm to distribute the load.
-Returns
Worker.
+Returns
[worker node key, worker node].
Returns Worker
Inherited from FixedClusterPool.chooseWorker
+Returns [number, WorkerNode<Worker, Data>]
Inherited from FixedClusterPool.chooseWorkerNode
-- Defined in src/pools/abstract-pool.ts:290
Protected
createCreates a new worker for this pool and sets it up completely.
+Creates a new worker and sets it up completely in the pool worker nodes.
Returns
New, completely set up worker.
Returns Worker
Inherited from FixedClusterPool.createAndSetupWorker
-- Defined in src/pools/abstract-pool.ts:344
Protected
create@@ -350,7 +355,7 @@ Can be overridden.
Returns Worker
Inherited from FixedClusterPool.createWorker
-- Defined in src/pools/cluster/fixed.ts:88
destroy
@@ -361,7 +366,7 @@ Can be overridden.
Returns Promise<void>
Inherited from FixedClusterPool.destroy
-- Defined in src/pools/abstract-pool.ts:222
destroy Worker
@@ -377,7 +382,7 @@ Can be overridden.
Returns void
Inherited from FixedClusterPool.destroyWorker
-- Defined in src/pools/cluster/fixed.ts:69
execute
@@ -393,109 +398,27 @@ Can be overridden.
Returns Promise<Response>
Inherited from FixedClusterPool.execute
-- Defined in src/pools/abstract-pool.ts:208
find Free Worker
+find Free Worker Node Key
-- find
Free Worker(): false | Worker
+- find
Free Worker Node Key(): number
-
-
-
Inherit Doc
Returns false | Worker
Inherited from FixedClusterPool.findFreeWorker
--- Defined in src/pools/abstract-pool.ts:197
get Worker Average Tasks Run Time
--- get
Worker Average Tasks Run Time(worker: Worker): undefined | number
--
-
-
-
-
-
-
Inherit Doc
Parameters
---
-
worker: Worker
Returns undefined | number
Inherited from FixedClusterPool.getWorkerAverageTasksRunTime
--- Defined in src/pools/abstract-pool.ts:169
get Worker Index
--- get
Worker Index(worker: Worker): number
--
-
-
-
-
-
Inherit Doc
Parameters
---
-
worker: Worker
Returns number
Inherited from FixedClusterPool.getWorkerIndex
--- Defined in src/pools/abstract-pool.ts:159
get Worker Running Tasks
--- get
Worker Running Tasks(worker: Worker): undefined | number
--
-
-
-
-
-
-
Inherit Doc
Parameters
---
-
worker: Worker
Returns undefined | number
Inherited from FixedClusterPool.getWorkerRunningTasks
--- Defined in src/pools/abstract-pool.ts:164
init Worker Tasks Usage
--- init
Worker Tasks Usage(worker: Worker): void
--
-
-
-
-
-
Initializes tasks usage statistics.
-Parameters
---
-
worker: Worker
-The worker.
-Returns void
Inherited from FixedClusterPool.initWorkerTasksUsage
--- Defined in src/pools/abstract-pool.ts:480
Execute
-Protected
internal-- internal
Execute(worker: Worker, messageId: number): Promise<Response>
--
-
-
-
-
Parameters
---
-
--
-
worker: Worker
messageId: number
Returns Promise<Response>
Inherited from FixedClusterPool.internalExecute
+Inherited from FixedClusterPool.findFreeWorkerNodeKey
-- Defined in src/pools/abstract-pool.ts:315
Get Busy Status
+Protected
internalProtected
internal-- internal
Get Busy Status(): boolean
+- internal
Busy(): boolean
-
-
Returns boolean
Inherited from FixedClusterPool.internalGetBusyStatus
+Inherited from FixedClusterPool.internalBusy
-- Defined in src/pools/abstract-pool.ts:189
Protected
is@@ -506,7 +429,7 @@ Can be overridden.
Returns boolean
Inherited from FixedClusterPool.isMain
-- Defined in src/pools/cluster/fixed.ts:64
register Worker Message Listener
@@ -540,25 +463,7 @@ Can be overridden.
Returns void
Inherited from FixedClusterPool.registerWorkerMessageListener
-- Defined in src/pools/cluster/fixed.ts:80
Worker
-Protected
remove-- remove
Worker(worker: Worker): void
--
-
-
-
-
-
Removes the given worker from the pool.
-Parameters
---
-
worker: Worker
-The worker that will be removed.
-Returns void
Inherited from FixedClusterPool.removeWorker
--- Defined in src/pools/abstract-pool.ts:277
Protected
send@@ -576,11 +481,11 @@ Can be overridden.
Returns void
Inherited from FixedClusterPool.sendToWorker
-- Defined in src/pools/cluster/fixed.ts:75
set Worker Choice Strategy
-- set
Worker Choice Strategy(workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"): void
+- set
Worker Choice Strategy(workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"): void
-
@@ -588,11 +493,11 @@ Can be overridden.
-
-
Inherit Doc
Parameters
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
Returns void
Inherited from FixedClusterPool.setWorkerChoiceStrategy
-- Defined in src/pools/abstract-pool.ts:174
Protected
setup@@ -603,13 +508,13 @@ Can be overridden.
Returns void
Inherited from FixedClusterPool.setupHook
-- Defined in src/pools/cluster/fixed.ts:59
Protected
workerThis function is the listener registered for each worker.
+This function is the listener registered for each worker message.
Returns
The listener function to execute when a message is received from a worker.
This function is the listener registered for each worker.
+This function is the listener registered for each worker message.
Returns
The listener function to execute when a message is received from a worker.
Returns void
Inherited from FixedClusterPool.workerListener
-- Defined in src/pools/abstract-pool.ts:368
@@ -660,36 +565,30 @@ Can be overridden.- constructor
- emitter?
- file
Path
-- max
-- next
Message Id
+- max
- number
Of Workers
- opts
-- promise
Map
+- promise
Response Map
- worker
Choice Strategy Context
-- workers
-- workers
Tasks Usage
+- worker
Nodes
- busy
-- number
Of Running Tasks
+- full
+- number
Of Queued Tasks
+- number
Of Running Tasks
- type
-- after
Promise Worker Response Hook
+- after
Task Execution Hook
- after
Worker Setup
-- before
Promise Worker Response Hook
-- choose
Worker
+- before
Task Execution Hook
+- choose
Worker Node
- create
And Setup Worker
- create
Worker
- destroy
- destroy
Worker
- execute
-- find
Free Worker
-- get
Worker Average Tasks Run Time
-- get
Worker Index
-- get
Worker Running Tasks
-- init
Worker Tasks Usage
-- internal
Execute
-- internal
Get Busy Status
+- find
Free Worker Node Key
+- internal
Busy
- is
Main
- register
Worker Message Listener
-- remove
Worker
- send
To Worker
- set
Worker Choice Strategy
- setup
Hook