X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicClusterPool.html;h=f6c8e28904ec40bcc83cea1f4b18c802ba2ebd2a;hb=a34454964733f585af19a04f21f9e35eb18c77b1;hp=d0006825490796161e4ce0db9b8a44ebd8b38069;hpb=33c629765dcf8e17e2d3fa207a286b5d360fae78;p=poolifier.git diff --git a/docs/classes/DynamicClusterPool.html b/docs/classes/DynamicClusterPool.html index d0006825..f6c8e289 100644 --- a/docs/classes/DynamicClusterPool.html +++ b/docs/classes/DynamicClusterPool.html @@ -1,11 +1,13 @@
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
- -emitter
.Template
of data sent to the worker. This can only be serializable data.
- -Template
of response of execution. This can only be serializable data.
+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
.Author
Christopher Quadflieg
@@ -30,9 +28,13 @@ When the maximum number of workers is reached, an event is emitted. If you wantType Parameters
Data = unknown
Data = unknown
+Type of data sent to the worker. This can only be serializable data.
+Response = unknown
Response = unknown
+Type of response of execution. This can only be serializable data.
+Hierarchy
@@ -40,7 +42,7 @@ When the maximum number of workers is reached, an event is emitted. If you want- DynamicClusterPool
@@ -54,45 +56,45 @@ 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
-Optional
Readonly
emitterInherit 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:63
Of Workers
-Readonly
numberNumber of workers that this pool should manage.
+Inherited from FixedClusterPool.numberOfWorkers
-- Defined in src/pools/abstract-pool.ts:84
-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 promise response 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 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.
Inherited from FixedClusterPool.promiseMap
+Inherited from FixedClusterPool.promiseResponseMap
-- Defined in src/pools/abstract-pool.ts:55
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:70
-Readonly
workers Nodes
+Readonly
workerInherit Doc
Inherited from FixedClusterPool.workers
+Inherited from FixedClusterPool.workerNodes
-- Defined in src/pools/abstract-pool.ts:33
Tasks Usage
-Readonly
workersInherit Doc
Inherited from FixedClusterPool.workersTasksUsage
--- Defined in src/pools/abstract-pool.ts:36
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:156
type
@@ -250,13 +263,13 @@ 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
Promise Response Hook(worker: Worker, message: MessageValue<Response, unknown>): void
-
-
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:307
Worker Setup
-
-- Defined in src/pools/cluster/fixed.ts:93
+
+ Promise Response Hook
-
-- Defined in src/pools/abstract-pool.ts:236
+
+
-
-
+
+
-
-
-- Defined in src/pools/abstract-pool.ts:563
+
+ Tasks Queue By Worker
+
+
Hook executed after the worker task promise resolution. Can be overridden.
@@ -265,17 +278,17 @@ 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.afterPromiseResponseHook
-- Defined in src/pools/abstract-pool.ts:263
Protected
after@@ -291,11 +304,11 @@ 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
Promise Response Hook(workerNodeKey: number): void
-
-
-
-
-
-- Defined in src/pools/abstract-pool.ts:296
+
+ Worker Node
+
+
Hook executed before the worker task promise resolution. Can be overridden.
@@ -304,40 +317,40 @@ Can be overridden.Parameters
worker: Worker
-The worker.
+workerNodeKey: number
+The worker node key.
Returns void
Inherited from FixedClusterPool.beforePromiseWorkerResponseHook
+Inherited from FixedClusterPool.beforePromiseResponseHook
-- 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:340
And Setup Worker
- create
And Setup Worker(): Worker
-
-
+- Defined in src/pools/abstract-pool.ts:406
Worker
+- Defined in src/pools/cluster/fixed.ts:88
+
+
+- Defined in src/pools/abstract-pool.ts:259
-
-
+
+
-
-
-
-
+
+
-
-- Defined in src/pools/abstract-pool.ts:551
+
+
-
-
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@@ -348,7 +361,21 @@ Can be overridden.
Returns Worker
Inherited from FixedClusterPool.createWorker
-- Defined in src/pools/cluster/fixed.ts:88
Task
+Protected
dequeue+- dequeue
Task(workerNodeKey: number): undefined | Task<Data>
+-
+
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns undefined | Task<Data>
Inherited from FixedClusterPool.dequeueTask
++- Defined in src/pools/abstract-pool.ts:555
destroy
@@ -359,7 +386,7 @@ Can be overridden.
Returns Promise<void>
Inherited from FixedClusterPool.destroy
-- Defined in src/pools/abstract-pool.ts:222
destroy Worker
@@ -375,54 +402,27 @@ Can be overridden.
Returns void
Inherited from FixedClusterPool.destroyWorker
-- Defined in src/pools/cluster/fixed.ts:69
execute
--- execute(data: Data): Promise<Response>
+- Defined in src/pools/cluster/fixed.ts:69
Task
+Protected
enqueue+- enqueue
Task(workerNodeKey: number, task: Task<Data>): void
-
-
-
-
-
-
-
Inherit Doc
Parameters
data: Data
Returns Promise<Response>
Inherited from FixedClusterPool.execute
--- Defined in src/pools/abstract-pool.ts:210
find Free Worker
--- find
Free Worker(): false | Worker
--
-
-
-
-
Inherit Doc
Returns false | Worker
Inherited from FixedClusterPool.findFreeWorker
--- Defined in src/pools/abstract-pool.ts:199
get Worker Average Tasks Run Time
--- get
Worker Average Tasks Run Time(worker: Worker): undefined | number
--
-
-
-
-
-
-
Inherit Doc
Parameters
-+-
-
workerNodeKey: number
worker: Worker
Returns undefined | number
Inherited from FixedClusterPool.getWorkerAverageTasksRunTime
+task: Task<Data>
Returns void
Inherited from FixedClusterPool.enqueueTask
-- Defined in src/pools/abstract-pool.ts:171
get Worker Index
+execute
-- get
Worker Index(worker: Worker): number
+- execute(data: Data): Promise<Response>
-
@@ -430,70 +430,59 @@ Can be overridden.
-
-
Inherit Doc
Parameters
worker: Worker
Returns number
Inherited from FixedClusterPool.getWorkerIndex
+data: Data
Returns Promise<Response>
Inherited from FixedClusterPool.execute
-- Defined in src/pools/abstract-pool.ts:161
get Worker Running Tasks
+find Free Worker Node Key
-- get
Worker Running Tasks(worker: Worker): undefined | number
+- find
Free Worker Node Key(): number
-
-
-
-
-
+
Inherit Doc
Parameters
---
-
worker: Worker
Returns undefined | number
Inherited from FixedClusterPool.getWorkerRunningTasks
+Returns number
Inherited from FixedClusterPool.findFreeWorkerNodeKey
-- Defined in src/pools/abstract-pool.ts:166
init Worker Tasks Usage
--- init
Worker Tasks Usage(worker: Worker): void
+- Defined in src/pools/abstract-pool.ts:229
Tasks Queue
+Protected
flush+- flush
Tasks Queue(workerNodeKey: number): void
-
-
-
-
+
Initializes tasks usage statistics.
-Parameters
worker: Worker
-The worker.
-workerNodeKey: number
Returns void
Inherited from FixedClusterPool.initWorkerTasksUsage
+Inherited from FixedClusterPool.flushTasksQueue
-- Defined in src/pools/abstract-pool.ts:470
Execute
+Protected
internalProtected
flush-- internal
Execute(worker: Worker, messageId: number): Promise<Response>
+- flush
Tasks Queue By Worker(worker: Worker): void
-
-
-
--
-
-
-
Parameters
worker: Worker
messageId: number
Returns Promise<Response>
Inherited from FixedClusterPool.internalExecute
+worker: Worker
Returns void
Inherited from FixedClusterPool.flushTasksQueueByWorker
-- 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:191
Protected
is@@ -504,7 +493,7 @@ Can be overridden.
Returns boolean
Inherited from FixedClusterPool.isMain
-- Defined in src/pools/cluster/fixed.ts:64
register Worker Message Listener
@@ -538,25 +527,25 @@ Can be overridden.
Returns void
Inherited from FixedClusterPool.registerWorkerMessageListener
-- Defined in src/pools/cluster/fixed.ts:80
Worker
+Protected
removeProtected
remove-- remove
Worker(worker: Worker): void
+- remove
Worker Node(worker: Worker): void
-
-
-
-
+- Defined in src/pools/abstract-pool.ts:545
To Worker
+- Defined in src/pools/cluster/fixed.ts:75
+
Removes the given worker from the pool.
+Removes the given worker from the pool worker nodes.
Parameters
worker: Worker
-The worker that will be removed.
+The worker.
Returns void
Inherited from FixedClusterPool.removeWorker
+Inherited from FixedClusterPool.removeWorkerNode
-- Defined in src/pools/abstract-pool.ts:277
Protected
send@@ -574,11 +563,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
-
@@ -586,11 +575,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:176
Protected
setup@@ -601,13 +590,27 @@ Can be overridden.
Returns void
Inherited from FixedClusterPool.setupHook
-- Defined in src/pools/cluster/fixed.ts:59
Queue Length
+Protected
tasks+- tasks
Queue Length(workerNodeKey: number): number
+-
+
+
+
+
Parameters
++-
+
workerNodeKey: number
Returns number
Inherited from FixedClusterPool.tasksQueueLength
++- Defined in src/pools/abstract-pool.ts:559
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
@@ -658,39 +661,39 @@ 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
Promise Response Hook
- after
Worker Setup
-- before
Promise Worker Response Hook
-- choose
Worker
+- before
Promise Response Hook
+- choose
Worker Node
- create
And Setup Worker
- create
Worker
+- dequeue
Task
- destroy
- destroy
Worker
+- enqueue
Task
- 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
+- flush
Tasks Queue
+- flush
Tasks Queue By Worker
+- internal
Busy
- is
Main
- register
Worker Message Listener
-- remove
Worker
+- remove
Worker Node
- send
To Worker
- set
Worker Choice Strategy
- setup
Hook
+- tasks
Queue Length
- worker
Listener
Generated using TypeDoc