X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=docs%2Fclasses%2FDynamicClusterPool.html;h=e2e7da263b2e264ccf64dbf2fd63d77edcfb8cb1;hb=aee467366d8c393b79e7af82c6a7ab12338ee64e;hp=5e8ceb76f84d47a8c1fd4f1d335bec4060a9200f;hpb=c0b0686de0f8c5483b20b94fac97d2b8175c0556;p=poolifier.git diff --git a/docs/classes/DynamicClusterPool.html b/docs/classes/DynamicClusterPool.html index 5e8ceb76..e2e7da26 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,37 +56,33 @@ 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
-tasks
+promise Response Map
worker Choice Strategy Context
workers
Properties
Accessors
Methods
-constructor
-- new
Dynamic Cluster Pool<Data, Response>(min: number, max: number, filePath: string, opts??: ClusterPoolOptions): DynamicClusterPool<Data, Response>
+- new
Dynamic Cluster Pool<Data, Response>(min: number, max: number, filePath: string, opts?: ClusterPoolOptions): DynamicClusterPool<Data, Response>
-
@@ -125,95 +123,84 @@ When the maximum number of workers is reached, an event is emitted. If you want
-
-
Constructs a new poolifier dynamic cluster pool.
Path to an implementation of a
ClusterWorker
file, which can be relative or absolute.
+Optional
opts: ClusterPoolOptions = {}opts: ClusterPoolOptions = {}
Options for this dynamic cluster pool.
Returns DynamicClusterPool<Data, Response>
+Properties
-Optional
Readonly
emitterInherit Doc
Path
-Readonly
file
+Readonly
maxPrivate
Readonly
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:57
Of Workers
-Readonly
numberNumber of workers that this pool should manage.
+Inherited from FixedClusterPool.numberOfWorkers
-- Defined in src/pools/abstract-pool.ts:78
-Readonly
optsOptions for this fixed cluster pool.
+Inherited from FixedClusterPool.opts
-- Defined in src/pools/cluster/fixed.ts:47
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:49
-Readonly
tasksInherit Doc
Inherited from FixedClusterPool.tasks
--- Defined in src/pools/abstract-pool.ts:33
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:64
-Readonly
workersInherit Doc
Inherited from FixedClusterPool.workers
-- Defined in src/pools/abstract-pool.ts:30
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 Running Tasks
+Private
number+- get numberOfRunningTasks(): number
+-
+
Number of tasks concurrently running in the pool.
+Returns number
Inherited from FixedClusterPool.numberOfRunningTasks
-- Defined in src/pools/abstract-pool.ts:150
type
@@ -248,9 +246,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 Response Hook
+Protected
after+- after
Promise Response Hook(worker: Worker, message: MessageValue<Response, unknown>): void
+-
+
+
+
+
+
Hook executed after the worker task promise resolution. +Can be overridden.
+Parameters
++-
+
+-
+
worker: Worker
+The worker.
+message: MessageValue<Response, unknown>
+The received message.
+Returns void
Inherited from FixedClusterPool.afterPromiseResponseHook
++- Defined in src/pools/abstract-pool.ts:281
Protected
after@@ -266,21 +287,40 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns void
Inherited from FixedClusterPool.afterWorkerSetup
-- Defined in src/pools/cluster/fixed.ts:89
Promise Response Hook
+Protected
before+- before
Promise Response Hook(workerKey: number): void
+-
+
+
+
+
+
Hook executed before the worker task promise resolution. +Can be overridden.
+Parameters
++-
+
workerKey: number
+The worker key.
+Returns void
Inherited from FixedClusterPool.beforePromiseResponseHook
++- Defined in src/pools/abstract-pool.ts:270
Protected
choose-- choose
Worker(): Worker
+- choose
Worker(): [number, Worker]
-
-
-
+
+- Defined in src/pools/abstract-pool.ts:310
And Setup Worker
+- Defined in src/pools/abstract-pool.ts:356
Worker
-
-
+- Defined in src/pools/cluster/fixed.ts:88
+- Defined in src/pools/abstract-pool.ts:233
+- Defined in src/pools/cluster/fixed.ts:69
-
-
-
-- Defined in src/pools/abstract-pool.ts:217
+
+
-
-
-
-
-
-
-
-- Defined in src/pools/abstract-pool.ts:210
+
+ Busy
+- Defined in src/pools/abstract-pool.ts:202
Main
+- Defined in src/pools/cluster/fixed.ts:64
+- Defined in src/pools/cluster/fixed.ts:80
Worker
+- Defined in src/pools/abstract-pool.ts:479
To Worker
+- Defined in src/pools/cluster/fixed.ts:75
+
Choose a worker for the next task.
-The default implementation uses a round robin algorithm to distribute the load.
+Chooses a worker for the next task.
+The default uses a round robin algorithm to distribute the load.
-Returns
Worker.
+Returns
[worker key, worker].
Returns Worker
Returns [number, Worker]
Inherited from FixedClusterPool.chooseWorker
-- Defined in src/pools/abstract-pool.ts:283
Protected
create@@ -293,7 +333,7 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns Worker
Inherited from FixedClusterPool.createAndSetupWorker
-- Defined in src/pools/abstract-pool.ts:337
Protected
create@@ -304,25 +344,7 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns Worker
Inherited from FixedClusterPool.createWorker
-- Defined in src/pools/cluster/fixed.ts:84
Workers Tasks
-Protected
decrease-- decrease
Workers Tasks(worker: Worker): void
--
-
-
-
-
-
Decrease the number of tasks that the given worker has applied.
-Parameters
---
-
worker: Worker
-Worker whose tasks are decreased.
-Returns void
Inherited from FixedClusterPool.decreaseWorkersTasks
--- Defined in src/pools/abstract-pool.ts:246
destroy
@@ -333,7 +355,7 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns Promise<void>
Inherited from FixedClusterPool.destroy
-- Defined in src/pools/abstract-pool.ts:208
destroy Worker
@@ -349,7 +371,7 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns void
Inherited from FixedClusterPool.destroyWorker
-- Defined in src/pools/cluster/fixed.ts:65
execute
@@ -365,93 +387,27 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns Promise<Response>
Inherited from FixedClusterPool.execute
-- Defined in src/pools/abstract-pool.ts:196
find Free Worker
--- find
Free Worker(): false | Worker
--
-
-
-
-
Inherit Doc
Returns false | Worker
Inherited from FixedClusterPool.findFreeWorker
--- Defined in src/pools/abstract-pool.ts:185
get Worker Index
+find Free Worker Key
-- get
Worker Index(worker: Worker): number
+- find
Free Worker Key(): number
-
-
-
-
Inherit Doc
Parameters
---
-
worker: Worker
Returns number
Inherited from FixedClusterPool.getWorkerIndex
--- Defined in src/pools/abstract-pool.ts:160
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:155
Workers Task
-Protected
increase-- increase
Workers Task(worker: Worker): void
--
-
-
-
-
-
Increase the number of tasks that the given worker has applied.
-Parameters
---
-
worker: Worker
-Worker whose tasks are increased.
-Returns void
Inherited from FixedClusterPool.increaseWorkersTask
--- Defined in src/pools/abstract-pool.ts:237
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.findFreeWorkerKey
-- Defined in src/pools/abstract-pool.ts:308
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:177
Protected
is@@ -462,7 +418,7 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns boolean
Inherited from FixedClusterPool.isMain
-- Defined in src/pools/cluster/fixed.ts:60
register Worker Message Listener
@@ -496,7 +452,7 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns void
Inherited from FixedClusterPool.registerWorkerMessageListener
-- Defined in src/pools/cluster/fixed.ts:76
Protected
remove@@ -509,12 +465,12 @@ When the maximum number of workers is reached, an event is emitted. If you want-
worker: Worker
-Worker that will be removed.
+The worker that will be removed.
Returns void
Inherited from FixedClusterPool.removeWorker
-- Defined in src/pools/abstract-pool.ts:270
Protected
send@@ -532,11 +488,11 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns void
Inherited from FixedClusterPool.sendToWorker
-- Defined in src/pools/cluster/fixed.ts:71
set Worker Choice Strategy
-- set
Worker Choice Strategy(workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED"): void
+- set
Worker Choice Strategy(workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"): void
-
@@ -544,11 +500,11 @@ When the maximum number of workers is reached, an event is emitted. If you want
-
-
Inherit Doc
Parameters
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED"
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:165
Protected
setup@@ -559,7 +515,7 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns void
Inherited from FixedClusterPool.setupHook
-- Defined in src/pools/cluster/fixed.ts:53
Protected
worker@@ -587,7 +543,7 @@ When the maximum number of workers is reached, an event is emitted. If you want
Returns void
Inherited from FixedClusterPool.workerListener
-- Defined in src/pools/abstract-pool.ts:361
@@ -616,31 +572,27 @@ When the maximum number of workers is reached, an event is emitted. If you wantconstructor
emitter?
file Path
-max
-next Message Id
+max
number Of Workers
opts
-promise Map
-tasks
+promise Response Map
worker Choice Strategy Context
workers
busy
-number Of Running Tasks
+full
+number Of Running Tasks
type
+after Promise Response Hook
after Worker Setup
+before Promise Response Hook
choose Worker
create And Setup Worker
create Worker
-decrease Workers Tasks
destroy
destroy Worker
execute
-find Free Worker
-get Worker Index
-get Worker Running Tasks
-increase Workers Task
-internal Execute
-internal Get Busy Status
+find Free Worker Key
+internal Busy
is Main
register Worker Message Listener
remove Worker