X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FFixedClusterPool.html;h=f37dcf026047aa78e86c830d0c6cde22c91cd0d4;hb=341ec6db3b66173fd9314338b736fabb0639914b;hp=6c8b461351fe597007ae467395a85e0ea1502703;hpb=fe9f25b5ac98c7c7fccd1849a200c5054a77cf03;p=poolifier.git diff --git a/docs/classes/FixedClusterPool.html b/docs/classes/FixedClusterPool.html index 6c8b4613..f37dcf02 100644 --- a/docs/classes/FixedClusterPool.html +++ b/docs/classes/FixedClusterPool.html @@ -1,13 +1,15 @@ -FixedClusterPool | poolifier
+FixedClusterPool | poolifier - v2.6.40
-
+
  • The search index is not available
  • poolifier - v2.6.40 +
    -
    +
    • poolifier
    • @@ -15,34 +17,35 @@

      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.

    - -

    Template

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

    - -

    Template

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

    - -

    Author

    Christopher Quadflieg

    +
    +
    +

    Author

    Christopher Quadflieg

    -

    Since

    2.0.0

    +

    Since

    2.0.0

    -
    +

    Type Parameters

    -
      +
      • -

        Data = unknown

      • +

        Data = unknown

        +

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

        +
        +
      • -

        Response = unknown

    +

    Response = unknown

    +

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

    +
    +

    Hierarchy

    @@ -50,546 +53,802 @@

    Constructors

    -
    - -
      - +
      + +
        +
      • Constructs a new poolifier fixed cluster pool.

        -
        +

        Type Parameters

        -
          +
          • -

            Data = unknown

          • +

            Data = unknown

          • -

            Response = unknown

        +

        Response = unknown

      Parameters

      • -
        numberOfWorkers: number
        +
        numberOfWorkers: number

        Number of workers for this pool.

      • -
        filePath: string
        +
        filePath: string

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

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

        Options for this fixed cluster pool.

      -

      Returns FixedClusterPool<Data, Response>

    +
  • Defined in src/pools/cluster/fixed.ts:44
  • Properties

    -
    - -
    emitter?: PoolEmitter
    -
    -

    Inherit Doc

    -
    - -
    filePath: string
    -
    - -
    max?: number
    -
    -

    Inherit Doc

    -
    - -
    nextMessageId: number = 0
    -

    Id of the next message.

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

    The 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.
    • +
      + +
      emitter?: PoolEmitter
      +

      Emitter on which events can be listened to.

      +

      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.
      • +
      • '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.
      • +
      • '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).
      -

      When we receive a message from the worker we get a map entry and resolve/reject the promise based on the message.

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

      Inherit Doc

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

      Worker choice strategy instance implementing the worker choice algorithm.

      -

      Default to a strategy implementing a round robin algorithm.

      -
      -
      - -
      workers: Worker[] = []
      -
      -

      Inherit Doc

    +
    +
    + +
    filePath: string
    +

    Path to the worker file.

    +
    +
    +
    + +
    max?: number
    +

    Dynamic pool maximum size property placeholder.

    +
    +
    +
    + +
    numberOfWorkers: number
    +

    Number of workers that this pool should manage.

    +
    +
    +
    + + +

    Options for this fixed cluster pool.

    +
    +
    +
    + +
    promiseResponseMap: Map<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 execution response promise resolve and reject callbacks.
    • +
    +

    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.

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

    Pool worker nodes.

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

    -
    - -
      +
      + +
      • get busy(): boolean
      • -
        -

        Inherit Doc

        -

        Returns boolean

      -
      - -
    +
    + +
    -
    - -
      -
    • get type(): PoolType
    • +

      Whether the pool is full or not.

      +

      The pool filling boolean status.

      +
      +

      Returns boolean

      +
    +
    + +
    +
    + +
      +
    • get maxSize(): number
    • +
    • +

      The pool maximum size.

      +
      +

      Returns number

      +
    +
    + +
      +
    • get minSize(): number
    • +
    • +

      The pool minimum size.

      +
      +

      Returns number

      +
    +
    + +
      +
    • get ready(): boolean
    • +
    • +

      The pool readiness boolean status.

      +
      +

      Returns boolean

      +
    +
    + +
      +
    • get type(): "fixed" | "dynamic"
    • +
    • +

      The pool type.

      +

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

      +
      +

      Returns "fixed" | "dynamic"

      +
    +
  • Defined in src/pools/cluster/fixed.ts:114
  • +
    + +
      +
    • get utilization(): number
    • +
    • +

      The approximate pool utilization.

      +
      +

      Returns number

      The pool utilization.

      + +
    +
    + +
      +
    • get worker(): "thread" | "cluster"
    • +
    • +

      The worker type.

      +
      +

      Returns "thread" | "cluster"

      +

    Methods

    -
    - -
      - +
      + +
        +
      • -
        -

        Inherit Doc

        +

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

        +

        Parameters

        • -
          worker: Worker
        -

        Returns void

      -
      - -
        - -
      • -

        Choose a worker for the next task.

        -

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

        - -

        Returns

        Worker.

        -
        -

        Returns Worker

      -
      - -
        - +
        workerNodeKey: number
        +

        The worker node key.

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

        The received message.

        +
    +

    Returns void

    +
    +
    + +
      +
    • -

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

      - -

      Returns

      New, completely set up worker.

      +

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

      -

      Returns Worker

    -
    - -
    -
    - -
    +
    + +
      +
    • -

      Decrease the number of tasks that the given worker has applied.

      +

      Hook executed before the worker task execution. +Can be overridden.

      Parameters

      • -
        worker: Worker
        -

        Worker whose tasks are decreased.

        +
        workerNodeKey: number
        +

        The worker node key.

        +
      • +
      • +
        task: Task<Data>
        +

        The task to execute.

      -

      Returns void

    -
    - -
    +
    + +
      +
    • -
      -

      Inherit Doc

      -

      Returns Promise<void>

    -
    - -
      - -
    • -
      -

      Inherit Doc

      Parameters

      • -
        worker: Worker
      +
      min: number
    • +
    • +
      max: number

    Returns void

    -
    - -
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    -
    - -
    -
    - -
    +

    Returns Promise<void>

    +
    +
    + +
    -
    - - +

    Returns void

    +
    +
    + +
    -
    - - +

    Returns Promise<Response>

    Promise that will be fulfilled when the task is completed.

    + +
    +
    + +

    Returns void

    -
    - -
    +
    + +
    +
    + +
    -
    - - +

    Returns boolean

    true if the worker node has back pressure, false otherwise.

    + +
    +
    + +
    -
    - -
    +
    + +
    -
    - -
    +
    + +
    +
    + +

    Parameters

    Returns void

    -

    Returns void

    -
    - -
    +
    + +
    +
    + +
    -
    - -
    +
    + +
    -
    - - +

    Returns void

    +
    +
    + +
    -
    - - +

    Returns void

    +
    +
    + +
    -
    - -
    +
    + +
    +
    + +
    +
    + + +
    - +
    +
    +
    +

    On This Page

    - -
    -

    Generated using TypeDoc

    -
    \ No newline at end of file +
  • constructor
  • +
  • emitter
  • +
  • filePath
  • +
  • max
  • +
  • numberOfWorkers
  • +
  • opts
  • +
  • promiseResponseMap
  • +
  • workerChoiceStrategyContext
  • +
  • workerNodes
  • +
  • busy
  • +
  • full
  • +
  • info
  • +
  • maxSize
  • +
  • minSize
  • +
  • ready
  • +
  • type
  • +
  • utilization
  • +
  • worker
  • +
  • afterTaskExecutionHook
  • +
  • afterWorkerNodeSetup
  • +
  • beforeTaskExecutionHook
  • +
  • checkDynamicPoolSize
  • +
  • createAndSetupDynamicWorkerNode
  • +
  • createAndSetupWorkerNode
  • +
  • createWorker
  • +
  • destroy
  • +
  • destroyWorkerNode
  • +
  • enableTasksQueue
  • +
  • execute
  • +
  • flushTasksQueue
  • +
  • getWorkerInfo
  • +
  • hasWorkerNodeBackPressure
  • +
  • internalBusy
  • +
  • isMain
  • +
  • listTaskFunctions
  • +
  • registerWorkerMessageListener
  • +
  • sendKillMessageToWorker
  • +
  • sendStartupMessageToWorker
  • +
  • sendToWorker
  • +
  • setTasksQueueOptions
  • +
  • setWorkerChoiceStrategy
  • +
  • setWorkerChoiceStrategyOptions
  • +
  • setupHook
  • +
  • workerListener
  • + +
    +

    Generated using TypeDoc

    +
    \ No newline at end of file