Skip to main content
The Deno 2 Release Candidate is here
Learn more
Latest
class AbstractWorkerChoiceStrategy
Abstract
import { AbstractWorkerChoiceStrategy } from "https://deno.land/x/poolifier@v0.3.14/src/pools/selection-strategies/abstract-worker-choice-strategy.ts";

Worker choice strategy abstract base class.

Constructors

new
AbstractWorkerChoiceStrategy(pool: IPool<Worker, Data, Response>, opts?: WorkerChoiceStrategyOptions)

Constructs a worker choice strategy bound to the pool.

Type Parameters

Worker extends IWorker
optional
Data = unknown
optional
Response = unknown

Properties

protected
nextWorkerNodeKey: number | undefined

The next worker node key.

protected
previousWorkerNodeKey: number

The previous worker node key.

readonly
strategyPolicy: StrategyPolicy
readonly
taskStatisticsRequirements: TaskStatisticsRequirements

Methods

private
toggleMedianMeasurementStatisticsRequirements(measurementStatisticsRequirements: MeasurementStatisticsRequirements, toggleMedian: boolean): void
protected
checkNextWorkerNodeKey(): void

Check the next worker node key.

protected
getWorkerNodeTaskRunTime(workerNodeKey: number): number

Gets the worker node task runtime. If the task statistics require the average runtime, the average runtime is returned. If the task statistics require the median runtime , the median runtime is returned.

protected
getWorkerNodeTaskWaitTime(workerNodeKey: number): number

Gets the worker node task wait time. If the task statistics require the average wait time, the average wait time is returned. If the task statistics require the median wait time, the median wait time is returned.

protected
isWorkerNodeReady(workerNodeKey: number): boolean

Whether the worker node is ready or not.

protected
setPreviousWorkerNodeKey(workerNodeKey: number | undefined): void

Sets safely the previous worker node key.

abstract
choose(): number | undefined
abstract
remove(workerNodeKey: number): boolean
abstract
reset(): boolean
setOptions(opts: WorkerChoiceStrategyOptions | undefined): void
abstract
update(workerNodeKey: number): boolean