import type { IWorker } from '../worker'
import type { IPool } from '../pool'
-import {
- DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
- DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
-} from '../../utils'
+import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../../utils'
import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
import type {
IWorkerChoiceStrategy,
- TaskStatisticsRequirements,
- WorkerChoiceStrategyOptions
+ InternalWorkerChoiceStrategyOptions,
+ TaskStatisticsRequirements
} from './selection-strategies-types'
/**
elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS
}
- /**
- * Default worker weight.
- */
- private readonly defaultWorkerWeight: number
/**
* Worker node virtual task runtime.
*/
/** @inheritDoc */
public constructor (
pool: IPool<Worker, Data, Response>,
- opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
+ opts: InternalWorkerChoiceStrategyOptions
) {
super(pool, opts)
this.setTaskStatisticsRequirements(this.opts)
- this.defaultWorkerWeight = this.computeDefaultWorkerWeight()
}
/** @inheritDoc */
}
private weightedRoundRobinNextWorkerNodeKey (): number | undefined {
- const workerWeight =
- this.opts.weights?.[
- this.nextWorkerNodeKey ?? this.previousWorkerNodeKey
- ] ?? this.defaultWorkerWeight
+ const workerWeight = this.opts.weights?.[
+ this.nextWorkerNodeKey ?? this.previousWorkerNodeKey
+ ] as number
if (this.workerNodeVirtualTaskRunTime < workerWeight) {
this.workerNodeVirtualTaskRunTime =
this.workerNodeVirtualTaskRunTime +