X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=docs%2Fclasses%2FFixedClusterPool.html;h=52eb64fb30d9efb69f84f8098d5120ed1ee0232f;hb=53221c4e8cbcc585c670275e7c1c700c3d1b5f37;hp=4d368148e5a6212933aff0a193c51e08be7bd574;hpb=cfc6e8df4c903b63514c46cb67b3f5e24079d3ce;p=poolifier.git diff --git a/docs/classes/FixedClusterPool.html b/docs/classes/FixedClusterPool.html index 4d368148..52eb64fb 100644 --- a/docs/classes/FixedClusterPool.html +++ b/docs/classes/FixedClusterPool.html @@ -1,4 +1,4 @@ -
Type of response of execution. This can only be serializable data.
+Type of execution response. This can only be serializable data.
Hierarchy
-- AbstractPool<Worker, Data, Response>
+
- AbstractPool<Worker, Data, Response>
- FixedClusterPool
- DynamicClusterPool
@@ -58,41 +58,40 @@emitter?
file Path
-next Message Id
number Of Workers
opts
-promise Map
+promise Response Map
worker Choice Strategy Context
-workers
-workers Tasks Usage
+worker Nodes
Properties
Accessors
-Methods
-constructor
-- new
Fixed Cluster Pool<Data, Response>(numberOfWorkers: number, filePath: string, opts?: ClusterPoolOptions): FixedClusterPool<Data, Response>
+- new
Fixed Cluster Pool<Data, Response>(numberOfWorkers: number, filePath: string, opts?: ClusterPoolOptions): FixedClusterPool<Data, Response>
-
@@ -124,354 +123,353 @@
-
-
Constructs a new poolifier fixed cluster pool.
Path to an implementation of a
ClusterWorker
file, which can be relative or absolute.opts: ClusterPoolOptions = EMPTY_OBJECT_LITERAL
+opts: ClusterPoolOptions = {}
Options for this fixed cluster pool.
Returns FixedClusterPool<Data, Response>
Properties
Optional
Readonly
emitter{@inheritDoc}
+Emitter on which events can be listened to.
+Events that can currently be listened to:
++
+
+
'full'
: Emitted when the pool is dynamic and full.'busy'
: Emitted when the pool is busy.Inherited from AbstractPool.emitter
+Inherited from AbstractPool.emitter
-- Defined in src/pools/abstract-pool.ts:40
Readonly
filePath to the worker-file.
Inherited from AbstractPool.filePath
+Inherited from AbstractPool.filePath
-- Defined in src/pools/abstract-pool.ts:80
Message Id
-Protected
nextId of the next message.
-Inherited from AbstractPool.nextMessageId
--- Defined in src/pools/abstract-pool.ts:58
Readonly
numberNumber of workers that this pool should manage.
Inherited from AbstractPool.numberOfWorkers
+Inherited from AbstractPool.numberOfWorkers
-- Defined in src/pools/abstract-pool.ts:79
-Readonly
optsOptions for this fixed cluster pool.
Inherited from AbstractPool.opts
+Inherited from AbstractPool.opts
-- Defined in src/pools/cluster/fixed.ts:54
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 AbstractPool.promiseMap
+Inherited from AbstractPool.promiseResponseMap
-- Defined in src/pools/abstract-pool.ts:50
Choice Strategy Context
-Protected
workerWorker choice strategy instance implementing the worker choice algorithm.
-Default to a strategy implementing a round robin algorithm.
-Inherited from AbstractPool.workerChoiceStrategyContext
--- Defined in src/pools/abstract-pool.ts:65
-Readonly
workers{@inheritDoc}
+Worker choice strategy context referencing a worker choice algorithm implementation.
+Default to a round robin algorithm.
Inherited from AbstractPool.workers
+Inherited from AbstractPool.workerChoiceStrategyContext
-- Defined in src/pools/abstract-pool.ts:31
Tasks Usage
-Readonly
workers{@inheritDoc}
+ Nodes
+Readonly
workerPool worker nodes.
Inherited from AbstractPool.workersTasksUsage
+Inherited from AbstractPool.workerNodes
-- Defined in src/pools/abstract-pool.ts:34
Accessors
-busy
-+
+- get busy(): boolean
-
-
-
-
+
+
+
+
+
+- get numberOfRunningTasks(): number
-
-
+- Defined in src/pools/abstract-pool.ts:185
+Protected
busy{@inheritDoc}
+Whether the pool is busy or not.
+The pool busyness boolean status.
Returns boolean
Overrides AbstractPool.busy
-- Defined in src/pools/cluster/fixed.ts:105
number Of Running Tasks
-+- Defined in src/pools/cluster/fixed.ts:109
+Protected
full+- get full(): boolean
+-
+
+
+
Whether the pool is full or not.
+The pool filling boolean status.
+Returns boolean
Overrides AbstractPool.full
++- Defined in src/pools/cluster/fixed.ts:104
Of Queued Tasks
+Private
number+- get numberOfQueuedTasks(): number
+-
+
+
+
Number of tasks queued in the pool.
+Returns number
Inherited from AbstractPool.numberOfQueuedTasks
++- Defined in src/pools/abstract-pool.ts:195
Of Running Tasks
+Private
number{@inheritDoc}
+Number of tasks running in the pool.
Returns number
Inherited from AbstractPool.numberOfRunningTasks
-- Defined in src/pools/abstract-pool.ts:151
type
-- get type(): PoolType
+- get type(): PoolType
-
-
-
+
+- Defined in src/pools/cluster/fixed.ts:99
-
+ Task Execution Hook
{@inheritDoc}
+Pool type.
+If it is
'dynamic'
, it provides themax
property.Returns PoolType
Returns PoolType
Overrides AbstractPool.type
-- Defined in src/pools/cluster/fixed.ts:100
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:383
Worker Setup
- after
Worker Setup(worker: Worker): void
-
-
-
-
+
-
-
-- 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 AbstractPool.afterPromiseWorkerResponseHook
+Inherited from AbstractPool.afterTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:265
Protected
after{@inheritDoc}
+Function that can be hooked up when a worker has been newly created and moved to the pool worker nodes.
+Can be used to update the
maxListeners
or binding themain-worker
<->worker
connection if not bind by default.Parameters
worker: Worker
worker: Worker
+The newly created worker.
+Returns void
Overrides AbstractPool.afterWorkerSetup
+Overrides AbstractPool.afterWorkerSetup
-- Defined in src/pools/cluster/fixed.ts:94
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:372
+
+ Worker Node
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 AbstractPool.beforePromiseWorkerResponseHook
+Inherited from AbstractPool.beforeTaskExecutionHook
-- Defined in src/pools/abstract-pool.ts:254
Worker
+Protected
chooseProtected
choose-- choose
Worker(): Worker
+- choose
Worker Node(): [number, WorkerNode<Worker, Data>]
-
-
-
-
+
+- Defined in src/pools/abstract-pool.ts:416
And Setup Worker
- create
And Setup Worker(): Worker
-
-
-
+- Defined in src/pools/abstract-pool.ts:478
Worker
- create
Worker(): Worker
-
-
-
+- Defined in src/pools/cluster/fixed.ts:88
- destroy(): Promise<void>
-
-
-
-
-
+
+- destroy
Worker(worker: Worker): void
-
-
-
-
+
-
-
-- Defined in src/pools/cluster/fixed.ts:69
+
+
-
-- Defined in src/pools/abstract-pool.ts:250
+
+
-
-- Defined in src/pools/abstract-pool.ts:304
+
+
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 AbstractPool.chooseWorker
+Returns [number, WorkerNode<Worker, Data>]
Inherited from AbstractPool.chooseWorkerNode
-- Defined in src/pools/abstract-pool.ts:292
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 AbstractPool.createAndSetupWorker
+Inherited from AbstractPool.createAndSetupWorker
-- Defined in src/pools/abstract-pool.ts:336
Protected
create{@inheritDoc}
+Returns a newly created worker.
Returns Worker
Overrides AbstractPool.createWorker
+Overrides AbstractPool.createWorker
-- Defined in src/pools/cluster/fixed.ts:89
destroy
{@inheritDoc}
+Shutdowns every current worker in this pool.
Returns Promise<void>
Inherited from AbstractPool.destroy
+Inherited from AbstractPool.destroy
-- Defined in src/pools/abstract-pool.ts:220
destroy Worker
-+- Defined in src/pools/abstract-pool.ts:335
Worker
+Protected
destroy{@inheritDoc}
+Shutdowns the given worker.
Parameters
worker: Worker
worker: Worker
+A worker within
+workerNodes
.Returns void
Overrides AbstractPool.destroyWorker
+Overrides AbstractPool.destroyWorker
-- Defined in src/pools/cluster/fixed.ts:70
execute
+enable Tasks Queue
-- execute(data: Data): Promise<Response>
+- enable
Tasks Queue(enable: boolean, opts?: TasksQueueOptions): void
-
-
-
-
-
-
-
-
-
-
+
+
{@inheritDoc}
+Enables/disables the worker tasks queue in this pool.
Parameters
data: Data
Returns Promise<Response>
Inherited from AbstractPool.execute
--- Defined in src/pools/abstract-pool.ts:205
find Free Worker
--- find
Free Worker(): false | Worker
--
-
-
-
{@inheritDoc}
-Returns false | Worker
Inherited from AbstractPool.findFreeWorker
--- Defined in src/pools/abstract-pool.ts:194
get Worker Average Tasks Run Time
--- get
Worker Average Tasks Run Time(worker: Worker): undefined | number
--
-
-
-
-
-
{@inheritDoc}
-Parameters
-+
-
-
enable: boolean
+Whether to enable or disable the worker tasks queue.
+worker: Worker
Returns undefined | number
Inherited from AbstractPool.getWorkerAverageTasksRunTime
+Optional
opts: TasksQueueOptionsReturns void
Inherited from AbstractPool.enableTasksQueue
-- Defined in src/pools/abstract-pool.ts:166
get Worker Index
+execute
-- get
Worker Index(worker: Worker): number
+- execute(data: Data): Promise<Response>
-
-
-
-
-
-
+
+
{@inheritDoc}
+Executes the function specified in the constructor with the task data parameter.
+ +Returns
Promise that will be resolved when the task is successfully completed.
Parameters
worker: Worker
Returns number
Inherited from AbstractPool.getWorkerIndex
+data: Data
+The input for the specified task. This can only be serializable data.
+Returns Promise<Response>
Inherited from AbstractPool.execute
-- Defined in src/pools/abstract-pool.ts:156
get Worker Running Tasks
+find Free Worker Node Key
-- get
Worker Running Tasks(worker: Worker): undefined | number
+- find
Free Worker Node Key(): number
-
-
-
-
-
-
+
-
-- Defined in src/pools/abstract-pool.ts:297
+
+ Busy
+- Defined in src/pools/abstract-pool.ts:292
Main
- is
Main(): boolean
-
-
-
-
-
+
+
-
-
-
+
+
+
-
\ No newline at end of file
+
\ No newline at end of file
{@inheritDoc}
+Finds a free worker node key based on the number of tasks the worker has applied.
+If a worker is found with
+0
running tasks, it is detected as free and its worker node key is returned.If no free worker is found,
+ +-1
is returned.Returns
A worker node key if there is one,
-1
otherwise.Parameters
---
-
worker: Worker
Returns undefined | number
Inherited from AbstractPool.getWorkerRunningTasks
+Returns number
Inherited from AbstractPool.findFreeWorkerNodeKey
-- Defined in src/pools/abstract-pool.ts:161
Get Busy Status
+Protected
internalProtected
internal-- internal
Get Busy Status(): boolean
+- internal
Busy(): boolean
-
-
Returns boolean
Inherited from AbstractPool.internalGetBusyStatus
+Inherited from AbstractPool.internalBusy
-- Defined in src/pools/abstract-pool.ts:186
Protected
is{@inheritDoc}
+Should return whether the worker is the main worker or not.
Returns boolean
Overrides AbstractPool.isMain
+Overrides AbstractPool.isMain
-- Defined in src/pools/cluster/fixed.ts:65
register Worker Message Listener
--- register
Worker Message Listener<Message>(worker: Worker, listener: ((message: MessageValue<Message, unknown>) => void)): void
+- Defined in src/pools/cluster/fixed.ts:64
Worker Message Listener
+Protected
register+- register
Worker Message Listener<Message>(worker: Worker, listener: ((message: MessageValue<Message, unknown>) => void)): void
-
-
-
-
+
-
-
-
{@inheritDoc}
+Registers a listener callback on the given worker.
Type Parameters
@@ -482,103 +480,132 @@ Can be overridden.Parameters
worker: Worker
worker: Worker
+The worker which should register a listener.
+listener: ((message: MessageValue<Message, unknown>) => void)
+listener: ((message: MessageValue<Message, unknown>) => void)
+The message listener callback.
+-- (message: MessageValue<Message, unknown>): void
+- (message: MessageValue<Message, unknown>): void
-
-
-
+
Parameters
message: MessageValue<Message, unknown>
message: MessageValue<Message, unknown>
Returns void
Returns void
Overrides AbstractPool.registerWorkerMessageListener
+Overrides AbstractPool.registerWorkerMessageListener
-- Defined in src/pools/cluster/fixed.ts:81
Worker
-Protected
remove-- remove
Worker(worker: Worker): void
+- Defined in src/pools/cluster/fixed.ts:80
To Worker
+Protected
send+- send
To Worker(worker: Worker, message: MessageValue<Data, unknown>): void
-
-
-
+-
+
-
-
-
+
+
+- Defined in src/pools/abstract-pool.ts:261
+
+
+- Defined in src/pools/abstract-pool.ts:240
Hook
- setup
Hook(): void
-
-
-
+- Defined in src/pools/cluster/fixed.ts:59
Listener
-
-
+- Defined in src/pools/abstract-pool.ts:501
+
+
-
-
-
+- constructor
+- emitter
+- file
Path
+- number
Of Workers
+- opts
+- promise
Response Map
+- worker
Choice Strategy Context
+- worker
Nodes
+- busy
+- full
+- number
Of Queued Tasks
+- number
Of Running Tasks
+- type
+- after
Task Execution Hook
+- after
Worker Setup
+- before
Task Execution Hook
+- choose
Worker Node
+- create
And Setup Worker
+- create
Worker
+- destroy
+- destroy
Worker
+- enable
Tasks Queue
+- execute
+- find
Free Worker Node Key
+- internal
Busy
+- is
Main
+- register
Worker Message Listener
+- send
To Worker
+- set
Tasks Queue Options
+- set
Worker Choice Strategy
+- set
Worker Choice Strategy Options
+- setup
Hook
+- worker
Listener
+
+
Removes the given worker from the pool.
+Sends a message to the given worker.
Parameters
worker: Worker
-The worker that will be removed.
+The worker which should receive the message.
+message: MessageValue<Data, unknown>
+The message.
Returns void
Inherited from AbstractPool.removeWorker
+Overrides AbstractPool.sendToWorker
-- Defined in src/pools/abstract-pool.ts:279
To Worker
-Protected
send-- send
To Worker(worker: Worker, message: MessageValue<Data, unknown>): void
+- Defined in src/pools/cluster/fixed.ts:75
set Tasks Queue Options
++- set
Tasks Queue Options(opts: TasksQueueOptions): void
-
-
-
-
--
-
+
-
{@inheritDoc}
+Sets the worker tasks queue options in this pool.
Parameters
worker: Worker
message: MessageValue<Data, unknown>
opts: TasksQueueOptions
+The worker tasks queue options.
+Returns void
Overrides AbstractPool.sendToWorker
+Inherited from AbstractPool.setTasksQueueOptions
-- Defined in src/pools/cluster/fixed.ts:76
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
+-
+
+
+
+
+
Sets the worker choice strategy in this pool.
+Parameters
++-
+
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
+The worker choice strategy.
+Returns void
Inherited from AbstractPool.setWorkerChoiceStrategy
++- Defined in src/pools/abstract-pool.ts:218
set Worker Choice Strategy Options
++- set
Worker Choice Strategy Options(workerChoiceStrategyOptions: WorkerChoiceStrategyOptions): void
-
-
-
-
+
-
{@inheritDoc}
+Sets the worker choice strategy options in this pool.
Parameters
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
workerChoiceStrategyOptions: WorkerChoiceStrategyOptions
+The worker choice strategy options.
+Returns void
Inherited from AbstractPool.setWorkerChoiceStrategy
+Inherited from AbstractPool.setWorkerChoiceStrategyOptions
-- Defined in src/pools/abstract-pool.ts:171
Protected
setup{@inheritDoc}
+Setup hook to execute code before worker node are created in the abstract constructor. +Can be overridden
Returns void
Overrides AbstractPool.setupHook
+Overrides AbstractPool.setupHook
-- Defined in src/pools/cluster/fixed.ts:60
Protected
worker-- worker
Listener(): ((message: MessageValue<Response, unknown>) => void)
+- worker
Listener(): ((message: MessageValue<Response, unknown>) => void)
-
-
--
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 ((message: MessageValue<Response, unknown>) => void)
+Returns ((message: MessageValue<Response, unknown>) => void)
-- (message: MessageValue<Response, unknown>): void
+- (message: MessageValue<Response, unknown>): void
-
-
@@ -586,15 +613,16 @@ Can be overridden.
-
-
+
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.
Parameters
message: MessageValue<Response, unknown>
message: MessageValue<Response, unknown>
Returns void
Inherited from AbstractPool.workerListener
+Inherited from AbstractPool.workerListener
-- Defined in src/pools/abstract-pool.ts:362
-
+Settings
Settings
Member Visibility
Theme
Generated using TypeDoc