poolifier - v5.1.0
    Preparing search index...

    Class FixedClusterPool<Data, Response>

    A cluster pool with a fixed number of workers.

    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

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

      • OptionalmaximumNumberOfWorkers: number

        The maximum number of workers for this pool.

      Returns FixedClusterPool<Data, Response>

    Properties

    destroying: boolean

    Whether the pool is destroying or not.

    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.

    started: boolean

    Whether the pool is started or not.

    starting: boolean

    Whether the pool is starting or not.

    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