X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=docs%2Fclasses%2FDynamicClusterPool.html;h=108485539dfc24a44e7c1ad95fee7451016fd9fd;hb=0c1d2aee9268a3d1cad693d46d3ffe253e1f6a41;hp=50217700d3d438538d3e2a554db9b4ceb2498e99;hpb=d0f1dce33156fdb99f0ca3627839001909419497;p=poolifier.git
diff --git a/docs/classes/DynamicClusterPool.html b/docs/classes/DynamicClusterPool.html
index 50217700..10848553 100644
--- a/docs/classes/DynamicClusterPool.html
+++ b/docs/classes/DynamicClusterPool.html
@@ -1,54 +1,676 @@
-
DynamicClusterPool | poolifier Class DynamicClusterPool<Data, Response>
+
+Protected
worker Choice Strategy Context
+worker Choice Strategy Context: WorkerChoiceStrategyContext < Worker , Data , Response >
+
+
+Readonly
workers
+workers: Worker [] = []
+
+
+Readonly
workers Tasks Usage
+workers Tasks Usage: Map < Worker , TasksUsage > = ...
+
+
+Accessors
+
+busy
+
+get busy( ) : boolean
+
+
+Returns boolean
+
+number Of Running Tasks
+
+get numberOfRunningTasks( ) : number
+
+
+Returns number
+
+type
+
+get type( ) : PoolType
+
+
+Returns PoolType
+
+Methods
+
+Protected
after Promise Worker Response Hook
+
+after Promise Worker Response Hook( message: MessageValue < Response , unknown > , promise: PromiseWorkerResponseWrapper < Worker , Response > ) : void
+
+
+
+
Parameters
+
+
+message: MessageValue < Response , unknown >
+
+
+promise: PromiseWorkerResponseWrapper < Worker , Response >
+
+Returns void
+
+Protected
after Worker Setup
+
+after Worker Setup( worker: Worker ) : void
+
+
+
+Returns void
+
+Protected
before Promise Worker Response Hook
+
+before Promise Worker Response Hook( worker: Worker ) : void
+
+
+
+Returns void
+
+Protected
choose Worker
+
+choose Worker( ) : Worker
+
+
+Returns Worker
+
+Protected
create And Setup Worker
+
+create And Setup Worker( ) : Worker
+
+
+Returns Worker
+
+Protected
create Worker
+
+create Worker( ) : Worker
+
+
+Returns Worker
+
+destroy
+
+destroy( ) : Promise < void >
+
+
+Returns Promise < void >
+
+destroy Worker
+
+destroy Worker( worker: Worker ) : void
+
+
+
+Returns void
+
+execute
+
+execute( data: Data ) : Promise < Response >
+
+
+
+Returns Promise < Response >
+
+find Free Worker
+
+find Free Worker( ) : false | Worker
+
+
+Returns false | Worker
+
+get Worker Average Tasks Run Time
+
+get Worker Average Tasks Run Time( worker: Worker ) : undefined | number
+
+
+
+Returns undefined | number
+
+get Worker Index
+
+get Worker Index( worker: Worker ) : number
+
+
+
+Returns number
+
+get Worker Running Tasks
+
+get Worker Running Tasks( worker: Worker ) : undefined | number
+
+
+
+Returns undefined | number
+
+Protected
internal Execute
+
+internal Execute( worker: Worker , messageId: number ) : Promise < Response >
+
+
+
Parameters
+
+
+worker: Worker
+
+messageId: number
+Returns Promise < Response >
+
+Protected
internal Get Busy Status
+
+internal Get Busy Status( ) : boolean
+
+Returns boolean
+
+Protected
is Main
+
+is Main( ) : boolean
+
+
+Returns boolean
+
+register Worker Message Listener
+
+register Worker Message Listener< Message > ( worker: Worker , listener: ( ( message: MessageValue < Message , unknown > ) => void ) ) : void
+
+
+
+
+
Parameters
+
+
+worker: Worker
+
+listener: ( ( message: MessageValue < Message , unknown > ) => void )
+
+
+
+( message: MessageValue < Message , unknown > ) : void
+
+
+
Parameters
+
+
+message: MessageValue < Message , unknown >
+Returns void
+Returns void
+
+Protected
remove Worker
+
+remove Worker( worker: Worker ) : void
+
+
+
+Returns void
+
+Protected
send To Worker
+
+send To Worker( worker: Worker , message: MessageValue < Data , unknown > ) : void
+
+
+
+
Parameters
+
+
+worker: Worker
+
+message: MessageValue < Data , unknown >
+Returns void
+
+set Worker Choice Strategy
+
+set Worker Choice Strategy( workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN" ) : void
+
+
+
+
Parameters
+
+
+workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
+Returns void
+
+Protected
setup Hook
+
+setup Hook( ) : void
+
+
+Returns void
+
+Protected
worker Listener
+
+worker Listener( ) : ( ( message: MessageValue < Response , unknown > ) => void )
+
+
+Returns ( ( message: MessageValue < Response , unknown > ) => void )
+
+
+
+( message: MessageValue < Response , unknown > ) : void
+
+
+
+
Parameters
+
+
+message: MessageValue < Response , unknown >
+Returns void
+
+
+
\ No newline at end of file
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. +
+- Preparing search index...
+- The search index is not available
poolifier+- poolifier
+- DynamicClusterPool
+Class DynamicClusterPool<Data, Response>
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
.of data sent to the worker. This can only be serializable data.
-of response of execution. This can only be serializable data.
-Christopher Quadflieg
-2.0.0
-Type parameters
Data = unknown
Response = unknown
Hierarchy
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Constructs a new poolifier dynamic cluster pool.
-Type parameters
Data = unknown
Response = unknown
Parameters
min: number
Minimum number of workers which are always active.
-max: number
Maximum number of workers that can be created by this pool.
-filePath: string
Path to an implementation of a
-ClusterWorker
file, which can be relative or absolute.opts: ClusterPoolOptions = {}
Returns DynamicClusterPool<Data, Response>
Properties
Optional Readonly emitter
Readonly file Path
Readonly max
Protected next Message Id
Id of the next message.
-Readonly number Of Workers
Readonly opts
Protected promise Map
The promise map.
-+ +
Author
Christopher Quadflieg
+ +Since
2.0.0
+Type Parameters
++-
+
+-
+
Data = unknown
+Type of data sent to the worker. This can only be serializable data.
+Response = unknown
+Type of response of execution. This can only be serializable data.
+Hierarchy
++- FixedClusterPool<Data, Response>
+
+- DynamicClusterPool
+
+Index
Constructors
+Properties
+Accessors
+Methods
+Constructors
+constructor
++- new
Dynamic Cluster Pool<Data, Response>(min: number, max: number, filePath: string, opts?: ClusterPoolOptions): DynamicClusterPool<Data, Response>
+-
+
+
+
+
+
+
Constructs a new poolifier dynamic cluster pool.
+Type Parameters
++-
+
+-
+
Data = unknown
Response = unknown
Parameters
++-
+
+-
+
+-
+
+-
+
min: number
+Minimum number of workers which are always active.
+max: number
+Maximum number of workers that can be created by this pool.
+filePath: string
+Path to an implementation of a
+ClusterWorker
file, which can be relative or absolute.opts: ClusterPoolOptions = {}
+Options for this dynamic cluster pool.
+Returns DynamicClusterPool<Data, Response>
Properties
+
+Optional
Readonly
emitterInherit Doc
Path
+Readonly
file
+Protected
Readonly
max Message Id
+Protected
nextId of the next message.
+ Of Workers
+Readonly
number
+Readonly
opts Map
+Protected
promiseThe 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.When we receive a message from the worker we get a map entry and resolve/reject the promise based on the message.
-Readonly tasks
Protected worker Choice Strategy Context
Worker choice strategy instance implementing the worker choice algorithm.
-Default to a strategy implementing a round robin algorithm.
-Readonly workers
Accessors
busy
Returns boolean
number Of Running Tasks
Returns number
type
Returns PoolType
Methods
Protected after Worker Setup
Parameters
worker: Worker
Returns void
Protected choose Worker
Choose a worker for the next task.
-The default implementation uses a round robin algorithm to distribute the load.
-Returns Worker
Worker.
-Protected create And Setup Worker
Creates a new worker for this pool and sets it up completely.
-Returns Worker
New, completely set up worker.
-Protected create Worker
Returns Worker
Protected decrease Workers Tasks
Decrease the number of tasks that the given worker has applied.
-Parameters
worker: Worker
Worker whose tasks are decreased.
-Returns void
destroy
Returns Promise<void>
destroy Worker
Parameters
worker: Worker
Returns void
execute
Parameters
data: Data
Returns Promise<Response>
find Free Tasks Map Entry
Returns false | [Worker, number]
Protected increase Workers Task
Increase the number of tasks that the given worker has applied.
-Parameters
worker: Worker
Worker whose tasks are increased.
-Returns void
Protected internal Execute
Parameters
worker: Worker
messageId: number
Returns Promise<Response>
Protected internal Get Busy Status
Returns boolean
Protected is Main
Returns boolean
register Worker Message Listener
Type parameters
Message
Parameters
worker: Worker
listener: (message: MessageValue<Message, unknown>) => void
Parameters
message: MessageValue<Message, unknown>
Returns void
Returns void
Protected remove Worker
Removes the given worker from the pool.
-Parameters
worker: Worker
Worker that will be removed.
-Returns void
Protected send To Worker
Parameters
worker: Worker
message: MessageValue<Data, unknown>
Returns void
set Worker Choice Strategy
Parameters
workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED"
Returns void
Protected setup Hook
Returns void
Protected worker Listener
This function is the listener registered for each worker.
-Returns (message: MessageValue<Response, unknown>) => void
The listener function to execute when a message is sent from a worker.
-This function is the listener registered for each worker.
-Parameters
message: MessageValue<Response, unknown>
Returns void
The listener function to execute when a message is sent from a worker.
-Generated using TypeDoc