Class WorkerChoiceStrategiesContext<Worker, Data, Response>

The worker choice strategies context.

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.

Constructors

Properties

retriesCount: number

The number of worker choice strategies execution retries.

Methods

  • Executes the given worker choice strategy in the context algorithm.

    Parameters

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

      The worker choice strategy algorithm to execute.

    Returns number

    The key of the worker node.

    this.defaultWorkerChoiceStrategy
    

    https://nodejs.org/api/errors.html#class-error 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:
          | "ROUND_ROBIN"
          | "LEAST_USED"
          | "LEAST_BUSY"
          | "LEAST_ELU"
          | "FAIR_SHARE"
          | "WEIGHTED_ROUND_ROBIN"
          | "INTERLEAVED_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<
          | "ROUND_ROBIN"
          | "LEAST_USED"
          | "LEAST_BUSY"
          | "LEAST_ELU"
          | "FAIR_SHARE"
          | "WEIGHTED_ROUND_ROBIN"
          | "INTERLEAVED_WEIGHTED_ROUND_ROBIN">

      The worker choice strategies to synchronize.

    • Optionalopts: WorkerChoiceStrategyOptions

      The worker choice strategy options.

    Returns void