X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicClusterPool.html;h=909eb463fafa2a8a77fd8217a6a920f8823018e5;hb=761b0c73be0bf581f50a78123913f933bd405f52;hp=50217700d3d438538d3e2a554db9b4ceb2498e99;hpb=d0f1dce33156fdb99f0ca3627839001909419497;p=poolifier.git diff --git a/docs/classes/DynamicClusterPool.html b/docs/classes/DynamicClusterPool.html index 50217700..909eb463 100644 --- a/docs/classes/DynamicClusterPool.html +++ b/docs/classes/DynamicClusterPool.html @@ -1,54 +1,736 @@ -DynamicClusterPool | poolifier
Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

-
template DataType

of data sent to the worker. This can only be serializable data.

-
template ResponseType

of response of execution. This can only be serializable data.

-
author

Christopher Quadflieg

-
since

2.0.0

-

Type parameters

  • Data = unknown

  • Response = unknown

Hierarchy

Index

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

emitter?: PoolEmitter

Readonly filePath

filePath: string

Readonly max

max: number

Protected nextMessageId

nextMessageId: number = 0
-

Id of the next message.

-

Readonly numberOfWorkers

numberOfWorkers: number

Readonly opts

Protected promiseMap

promiseMap: Map<number, PromiseWorkerResponseWrapper<Worker, Response>> = ...
-

The promise map.

-

Readonly tasks

tasks: Map<Worker, number> = ...

Protected workerChoiceStrategyContext

workerChoiceStrategyContext: WorkerChoiceStrategyContext<Worker, Data, Response>
-

Worker choice strategy instance implementing the worker choice algorithm.

-

Default to a strategy implementing a round robin algorithm.

-

Readonly workers

workers: Worker[] = []

Accessors

busy

  • get busy(): boolean

numberOfRunningTasks

  • get numberOfRunningTasks(): number

type

  • get type(): PoolType

Methods

Protected afterWorkerSetup

  • afterWorkerSetup(worker: Worker): void

Protected chooseWorker

  • chooseWorker(): Worker

Protected createAndSetupWorker

  • createAndSetupWorker(): Worker

Protected createWorker

  • createWorker(): Worker

Protected decreaseWorkersTasks

  • decreaseWorkersTasks(worker: Worker): void

destroy

  • destroy(): Promise<void>

destroyWorker

  • destroyWorker(worker: Worker): void

execute

  • execute(data: Data): Promise<Response>

findFreeTasksMapEntry

  • findFreeTasksMapEntry(): false | [Worker, number]

Protected increaseWorkersTask

  • increaseWorkersTask(worker: Worker): void

Protected internalExecute

  • internalExecute(worker: Worker, messageId: number): Promise<Response>

Protected internalGetBusyStatus

  • internalGetBusyStatus(): boolean

Protected isMain

  • isMain(): boolean

registerWorkerMessageListener

  • registerWorkerMessageListener<Message>(worker: Worker, listener: (message: MessageValue<Message, unknown>) => void): void

Protected removeWorker

  • removeWorker(worker: Worker): void

Protected sendToWorker

  • sendToWorker(worker: Worker, message: MessageValue<Data, unknown>): void

setWorkerChoiceStrategy

  • setWorkerChoiceStrategy(workerChoiceStrategy: "ROUND_ROBIN" | "LESS_RECENTLY_USED"): void

Protected setupHook

  • setupHook(): void

Protected workerListener

  • workerListener(): (message: MessageValue<Response, unknown>) => void
  • -

    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.

    -
      • (message: MessageValue<Response, unknown>): void
      • -

        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

\ No newline at end of file + +
+ +
filePath: string
+

Path to the worker file.

+
+
+ +
max: number
+

Maximum number of workers that can be created by this pool.

+
+
+ +
numberOfWorkers: number
+

Number of workers that this pool should manage.

+
+
+ +
opts: ClusterPoolOptions = {}
+

Options for this fixed cluster pool.

+
+
+ +
promiseResponseMap: Map<string, PromiseResponseWrapper<Worker, Response>> = ...
+

The execution response promise map.

+ +

When we receive a message from the worker, we get a map entry with the promise resolve/reject bound to the message id.

+
+
+ +
workerChoiceStrategyContext: WorkerChoiceStrategyContext<Worker, Data, Response>
+

Worker choice strategy context referencing a worker choice algorithm implementation.

+

Default to a round robin algorithm.

+
+
+ +
workerNodes: WorkerNode<Worker, Data>[] = []
+

Pool worker nodes.

+
+
+

Accessors

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+

Methods

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file