X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicClusterPool.html;h=6f720e7c98342ea3ac3d0427867ba85476e0aad9;hb=fa6436344997918dbda3e94063b4c2e2e4a892c3;hp=051f7ce50d1267c4d8f903d1404441fa329dbba0;hpb=e83f3916315e18f3ca0c614d6ec9e064ab76c13c;p=poolifier.git diff --git a/docs/classes/DynamicClusterPool.html b/docs/classes/DynamicClusterPool.html index 051f7ce5..6f720e7c 100644 --- a/docs/classes/DynamicClusterPool.html +++ b/docs/classes/DynamicClusterPool.html @@ -1,11 +1,13 @@ DynamicClusterPool | poolifier
-
+
@@ -16,11 +18,7 @@

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's emitter.

Author

Christopher Quadflieg

@@ -30,9 +28,13 @@ When the maximum number of workers is reached, an event is emitted. If you want

Type 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
+
  • Defined in src/pools/cluster/dynamic.ts:16
  • @@ -54,39 +56,33 @@ When the maximum number of workers is reached, an event is emitted. If you want

    Properties

    Accessors

    Methods

    -
    afterPromiseWorkerResponseHook +
    afterPromiseResponseHook afterWorkerSetup -beforePromiseWorkerResponseHook +beforePromiseResponseHook chooseWorker createAndSetupWorker createWorker destroy destroyWorker execute -findFreeWorker -getWorkerAverageTasksRunTime -getWorkerIndex -getWorkerRunningTasks -initWorkerTasksUsage -internalExecute -internalGetBusyStatus +findFreeWorkerKey +internalBusy isMain registerWorkerMessageListener removeWorker @@ -100,7 +96,7 @@ When the maximum number of workers is reached, an event is emitted. If you want
      - +
    • Constructs a new poolifier dynamic cluster pool.

      @@ -127,95 +123,84 @@ When the maximum number of workers is reached, an event is emitted. If you want

      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>

    +
  • Defined in src/pools/cluster/dynamic.ts:28
  • Properties

    -
    emitter?: PoolEmitter
    +
    emitter?: PoolEmitter

    Inherit Doc

    +
  • Defined in src/pools/abstract-pool.ts:32
  • -
    filePath: string
    -
    - +
  • Defined in src/pools/abstract-pool.ts:67
  • +
    +
    max: number
    -
    -

    Inherit Doc

    -
    - -
    nextMessageId: number = 0
    -

    Id of the next message.

    +

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

    +
  • Defined in src/pools/cluster/dynamic.ts:30
  • -
    numberOfWorkers: number
    +
  • Defined in src/pools/abstract-pool.ts:66
  • -
    -
    - -
    promiseMap: Map<number, PromiseWorkerResponseWrapper<Worker, Response>> = ...
    -

    The promise map.

    +
  • Defined in src/pools/cluster/fixed.ts:53
  • +
    + +
    promiseResponseMap: Map<string, PromiseResponseWrapper<Worker, Response>> = ...
    +

    The 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.

    +
  • Defined in src/pools/abstract-pool.ts:42
  • workerChoiceStrategyContext: WorkerChoiceStrategyContext<Worker, Data, Response>
    -

    Worker 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.

    +
  • Defined in src/pools/abstract-pool.ts:52
  • -
    workers: Worker[] = []
    +
    workers: WorkerType<Worker>[] = []

    Inherit Doc

    -
    - -
    workersTasksUsage: Map<Worker, TasksUsage> = ...
    -
    -

    Inherit Doc

    +
  • Defined in src/pools/abstract-pool.ts:29
  • Accessors

    @@ -228,18 +213,29 @@ When the maximum number of workers is reached, an event is emitted. If you want

    Returns boolean

    -
    - -
    +
    + +
    +
    + +
      +
    • get numberOfRunningTasks(): number
    • +
    • +

      Number of tasks concurrently running in the pool.

      +

      Returns number

    +
  • Defined in src/pools/abstract-pool.ts:163
    • @@ -250,13 +246,13 @@ When the maximum number of workers is reached, an event is emitted. If you want

      Returns PoolType

    +
  • Defined in src/pools/cluster/dynamic.ts:38
  • Methods

    -
    - +
    +
      - +
    • Hook executed after the worker task promise resolution. Can be overridden.

      @@ -265,17 +261,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

    +
  • Defined in src/pools/abstract-pool.ts:281
  • -
    - +
  • Defined in src/pools/cluster/fixed.ts:93
  • +
    +
    +
  • Defined in src/pools/abstract-pool.ts:270
    • - +
    • Chooses a worker for the next task.

      -

      The default implementation uses a round robin algorithm to distribute the load.

      +

      The default uses a round robin algorithm to distribute the load.

      -

      Returns

      Worker.

      +

      Returns

      [worker key, worker].

      -

      Returns Worker

    +
  • Defined in src/pools/abstract-pool.ts:310
  • +
  • Defined in src/pools/abstract-pool.ts:356
  • +
  • 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
  • +
    +
    +
  • Defined in src/pools/abstract-pool.ts:202
  • +
  • Defined in src/pools/cluster/fixed.ts:64
  • +
  • Defined in src/pools/cluster/fixed.ts:80
    • @@ -551,12 +465,12 @@ Can be overridden.

      • worker: Worker
        -

        Worker that will be removed.

        +

        The worker that will be removed.

    Returns void

    +
  • Defined in src/pools/abstract-pool.ts:479
  • +
  • Defined in src/pools/cluster/fixed.ts:75
    • - +
    • Inherit Doc

      @@ -586,11 +500,11 @@ Can be overridden.

      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

    +
  • Defined in src/pools/abstract-pool.ts:178
  • +
  • Defined in src/pools/cluster/fixed.ts:59
  • +
  • Defined in src/pools/abstract-pool.ts:385