X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FFixedClusterPool.html;h=4bdb14c01f1a94bc0a9d701fb445676225955730;hb=05a852b826fb54cbab49a196bbd0d123c3d0c367;hp=c17a4d099d0cdef2beedcda7b9fc0e2bc374f8ed;hpb=7cd8af0033b35def46016a78ea9be1ee516480bf;p=poolifier.git diff --git a/docs/classes/FixedClusterPool.html b/docs/classes/FixedClusterPool.html index c17a4d09..4bdb14c0 100644 --- a/docs/classes/FixedClusterPool.html +++ b/docs/classes/FixedClusterPool.html @@ -1,594 +1,140 @@ -FixedClusterPool | poolifier
-
- -
-
-
-
- -

Class FixedClusterPool<Data, Response>

-
-

A cluster pool with a fixed number of workers.

-

It is possible to perform tasks in sync or asynchronous mode as you prefer.

-

This pool selects the workers in a round robin fashion.

- -

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

-
-
-
-
- -
-
-

Constructors

-
- -
    - -
  • -

    Constructs a new poolifier fixed cluster pool.

    -
    -
    -

    Type Parameters

    -
      -
    • -

      Data = unknown

    • -
    • -

      Response = unknown

    -
    -

    Parameters

    -
      -
    • -
      numberOfWorkers: number
      -

      Number of workers for this pool.

      -
    • -
    • -
      filePath: string
      -

      Path to an implementation of a ClusterWorker file, which can be relative or absolute.

      -
    • -
    • -
      opts: ClusterPoolOptions = {}
      -

      Options for this fixed cluster pool.

      -
    -

    Returns FixedClusterPool<Data, Response>

-
-

Properties

-
- -
emitter?: PoolEmitter
-
-

Inherit Doc

-
- -
filePath: string
-

Path to the worker-file.

-
-
- -
numberOfWorkers: number
-

Number of workers that this pool should manage.

-
-
- - -

Options for this fixed cluster pool.

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

The promise response map.

+FixedClusterPool | poolifier - v4.0.10

Class FixedClusterPool<Data, Response>

A cluster pool with a fixed number of workers.

+

Author

Christopher Quadflieg

+

Since

2.0.0

+

Type Parameters

  • Data = unknown

    Type of data sent to the worker. This can only be structured-cloneable data.

    +
  • Response = unknown

    Type of execution response. This can only be structured-cloneable data.

    +

Hierarchy (view full)

Constructors

Properties

emitter?: EventEmitterAsyncResource

Pool event emitter integrated with async resource. +The async tracking tooling identifier is poolifier:<PoolType>-<WorkerType>-pool.

+

Events that can currently be listened to:

+
    +
  • 'ready': Emitted when the number of workers created in the pool has reached the minimum size expected and are ready. If the pool is dynamic with a minimum number of workers is set to zero, this event is emitted when at least one dynamic worker is ready.
  • +
  • 'busy': Emitted when the number of workers created in the pool has reached the maximum size expected and are executing concurrently their tasks quota.
  • +
  • 'full': Emitted when the pool is dynamic and the number of workers created has reached the maximum size expected.
  • +
  • 'empty': Emitted when the pool is dynamic with a minimum number of workers set to zero and the number of workers has reached the minimum size expected.
  • +
  • 'destroy': Emitted when the pool is destroyed.
  • +
  • 'error': Emitted when an uncaught error occurs.
  • +
  • 'taskError': Emitted when an error occurs while executing a task.
  • +
  • 'backPressure': Emitted when all worker nodes have back pressure (i.e. their tasks queue is full: queue size >= maximum queue size).
  • +
+
filePath: string

Path to the worker file.

+
maximumNumberOfWorkers?: number

Maximum number of workers that this pool manages.

+
minimumNumberOfWorkers: number

Minimum number of workers that this pool manages.

+
opts: PoolOptions<Worker>

Options for the pool.

+
promiseResponseMap: Map<`${string}-${string}-${string}-${string}-${string}`, PromiseResponseWrapper<Response>> = ...

The task execution response promise map:

  • key: The message id of each submitted task.
  • -
  • value: An object that contains the worker, the promise resolve and reject callbacks.
  • +
  • value: An object that contains task's worker node key, execution response promise resolve and reject callbacks, async resource.
-

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

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

Worker choice strategy context referencing a worker choice algorithm implementation.

-

Default to a round robin algorithm.

-
-
- -
workers: WorkerType<Worker>[] = []
-
-

Inherit Doc

-
-

Accessors

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

    Number of tasks concurrently running in the pool.

    -
    -

    Returns number

-
- -
-
-

Methods

-
- -
    - -
  • -

    Hook executed after the worker task promise resolution. +

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

    +
workerChoiceStrategiesContext?: WorkerChoiceStrategiesContext<Worker, Data, Response>

Worker choice strategies context referencing worker choice algorithms implementation.

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

Pool worker nodes.

+

Accessors

  • get busy(): boolean
  • Whether the pool is busy or not.

    +

    The pool busyness boolean status.

    +

    Returns boolean

  • get full(): boolean
  • Whether the pool is full or not.

    +

    The pool filling boolean status.

    +

    Returns boolean

  • get type(): "fixed" | "dynamic"
  • The pool type.

    +

    If it is 'dynamic', it provides the max property.

    +

    Returns "fixed" | "dynamic"

  • get utilization(): number
  • The approximate pool utilization.

    +

    Returns number

    The pool utilization.

    +
  • get worker(): "thread" | "cluster"
  • The worker type.

    +

    Returns "thread" | "cluster"

Methods

  • Hook executed after the worker task execution. Can be overridden.

    -
    -
    -

    Parameters

    -
      -
    • -
      worker: Worker
      -

      The worker.

      -
    • -
    • -
      message: MessageValue<Response, unknown>
      -

      The received message.

      -
    -

    Returns void

-
- -
    - -
  • -
    -

    Inherit Doc

    -
    -

    Parameters

    -
      -
    • -
      worker: Worker
    -

    Returns void

-
- -
  • Method hooked up after a worker node has been newly created. Can be overridden.

    -
    -
    -

    Parameters

    -
      -
    • -
      workerKey: number
      -

      The worker key.

      -
    -

    Returns void

-
- -
    - -
  • -

    Chooses a worker for the next task.

    -

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

    - -

    Returns

    [worker key, worker].

    -
    -

    Returns [number, Worker]

-
- -
    - -
  • -

    Creates a new worker for this pool and sets it up completely.

    - -

    Returns

    New, completely set up worker.

    -
    -

    Returns Worker

-
- -
-
- -
-
- -
    - -
  • -
    -

    Inherit Doc

    -
    -

    Parameters

    -
      -
    • -
      worker: Worker
    -

    Returns void

-
- -
    - -
  • -
    -

    Inherit Doc

    -
    -

    Parameters

    -
      -
    • -
      data: Data
    -

    Returns Promise<Response>

-
- -
    - -
  • -
    -

    Inherit Doc

    -

    Returns number

-
- -
-
- -
-
- -
    - -
  • -
    -

    Inherit Doc

    -
    -

    Type Parameters

    -
      -
    • -

      Message

    -
    -

    Parameters

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

          Parameters

          -
            -
          • -
            message: MessageValue<Message, unknown>
          -

          Returns void

    -

    Returns void

-
- -
    - -
  • -

    Removes the given worker from the pool.

    -
    -
    -

    Parameters

    -
      -
    • -
      worker: Worker
      -

      The worker that will be removed.

      -
    -

    Returns void

-
- -
    - -
  • -
    -

    Inherit Doc

    -
    -

    Parameters

    -
      -
    • -
      worker: Worker
    • -
    • -
      message: MessageValue<Data, unknown>
    -

    Returns void

-
- -
    - -
  • -
    -

    Inherit Doc

    -
    -

    Parameters

    -
      -
    • -
      workerChoiceStrategy: "ROUND_ROBIN" | "LESS_USED" | "LESS_BUSY" | "FAIR_SHARE" | "WEIGHTED_ROUND_ROBIN"
    -

    Returns void

-
- -
-
- -
    - -
  • -

    This function is the listener registered for each worker.

    - -

    Returns

    The listener function to execute when a message is received from a worker.

    -
    -

    Returns ((message: MessageValue<Response, unknown>) => void)

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

        This function is the listener registered for each worker.

        - -

        Returns

        The listener function to execute when a message is received from a worker.

        -
        -
        -

        Parameters

        -
          -
        • -
          message: MessageValue<Response, unknown>
        -

        Returns void

-
-
-

Generated using TypeDoc

-
\ No newline at end of file +

Parameters

  • workerNodeKey: number

    The newly created worker node key.

    +

Returns void

\ No newline at end of file