poolifier - v5.0.2
    Preparing search index...

    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 and workers are busy, an event is emitted. If you want to listen to this event, use the pool's emitter.

    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 Summary)

    Index

    Constructors

    Properties

    emitter?: EventEmitterAsyncResource
    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 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 id.

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

    Worker choice strategies context referencing worker choice algorithms implementation.

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

    Accessors

    • get backPressure(): boolean

      Whether the pool is back pressured or not.

      Returns boolean

      The pool back pressure boolean status.

    • get busy(): boolean

      Whether the pool is busy or not.

      Returns boolean

      The pool busyness boolean status.

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

      The pool type.

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

      Returns "fixed" | "dynamic"

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

      The worker type.

      Returns "cluster" | "thread"

    Methods

    • Parameters

      • Optionaldata: Data
      • Optionalname: string
      • OptionalabortSignal: AbortSignal
      • OptionaltransferList: readonly Transferable[]

      Returns Promise<Response>

    • Parameters

      • data: Iterable<Data>
      • Optionalname: string
      • OptionalabortSignals: Iterable<AbortSignal, any, any>
      • OptionaltransferList: readonly Transferable[]

      Returns Promise<Response[]>

    • Parameters

      • workerChoiceStrategy:
            | "FAIR_SHARE"
            | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"
            | "LEAST_BUSY"
            | "LEAST_ELU"
            | "LEAST_USED"
            | "ROUND_ROBIN"
            | "WEIGHTED_ROUND_ROBIN"
      • OptionalworkerChoiceStrategyOptions: WorkerChoiceStrategyOptions

      Returns void