poolifier - v5.3.2
    Preparing search index...

    Interface WorkerChoiceStrategiesContext<Worker, Data, Response>Internal

    The worker choice strategies context.

    interface WorkerChoiceStrategiesContext<
        Worker extends IWorker,
        Data = unknown,
        Response = unknown,
    > {
        execute(
            workerChoiceStrategy?:
                | "FAIR_SHARE"
                | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"
                | "LEAST_BUSY"
                | "LEAST_ELU"
                | "LEAST_USED"
                | "ROUND_ROBIN"
                | "WEIGHTED_ROUND_ROBIN",
            workerNodeKeysSet?: ReadonlySet<number>,
        ): number;
        getPolicy(): StrategyPolicy;
        getStrategyRetries(): number;
        getTaskStatisticsRequirements(): TaskStatisticsRequirements;
        remove(workerNodeKey: number): boolean;
        setDefaultWorkerChoiceStrategy(
            workerChoiceStrategy:
                | "FAIR_SHARE"
                | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"
                | "LEAST_BUSY"
                | "LEAST_ELU"
                | "LEAST_USED"
                | "ROUND_ROBIN"
                | "WEIGHTED_ROUND_ROBIN",
            opts?: WorkerChoiceStrategyOptions,
        ): void;
        setOptions(opts: WorkerChoiceStrategyOptions | undefined): void;
        syncWorkerChoiceStrategies(
            workerChoiceStrategies: Set<
                | "FAIR_SHARE"
                | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"
                | "LEAST_BUSY"
                | "LEAST_ELU"
                | "LEAST_USED"
                | "ROUND_ROBIN"
                | "WEIGHTED_ROUND_ROBIN",
            >,
            opts?: WorkerChoiceStrategyOptions,
        ): void;
        update(workerNodeKey: number): boolean;
    }

    Type Parameters

    • Worker extends IWorker

      Type of worker.

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

    Index

    Methods

    • Executes the given worker choice strategy.

      Parameters

      • workerChoiceStrategy:
            | "FAIR_SHARE"
            | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"
            | "LEAST_BUSY"
            | "LEAST_ELU"
            | "LEAST_USED"
            | "ROUND_ROBIN"
            | "WEIGHTED_ROUND_ROBIN" = ...

        The worker choice strategy.

      • OptionalworkerNodeKeysSet: ReadonlySet<number>

        The worker node keys affinity set. If undefined, all workers are eligible.

      Returns number

      The key of the worker node.

      If after computed retries the worker node key is null or undefined.

    • Sets the default worker choice strategy to use in the context.

      Parameters

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

        The default worker choice strategy to set.

      • Optionalopts: WorkerChoiceStrategyOptions

        The worker choice strategy options.

      Returns void

    • Synchronizes the active worker choice strategies in the context with the given worker choice strategies.

      Parameters

      • workerChoiceStrategies: Set<
            | "FAIR_SHARE"
            | "INTERLEAVED_WEIGHTED_ROUND_ROBIN"
            | "LEAST_BUSY"
            | "LEAST_ELU"
            | "LEAST_USED"
            | "ROUND_ROBIN"
            | "WEIGHTED_ROUND_ROBIN",
        >

        The worker choice strategies to synchronize.

      • Optionalopts: WorkerChoiceStrategyOptions

        The worker choice strategy options.

      Returns void