-import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../../utils.js'
import type { IPool } from '../pool.js'
+import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../utils.js'
import type { IWorker } from '../worker.js'
import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy.js'
import {
type IWorkerChoiceStrategy,
- type InternalWorkerChoiceStrategyOptions,
Measurements,
- type TaskStatisticsRequirements
+ type TaskStatisticsRequirements,
+ type WorkerChoiceStrategyOptions
} from './selection-strategies-types.js'
/**
/** @inheritDoc */
public constructor (
pool: IPool<Worker, Data, Response>,
- opts: InternalWorkerChoiceStrategyOptions
+ opts?: WorkerChoiceStrategyOptions
) {
super(pool, opts)
this.setTaskStatisticsRequirements(this.opts)
}
private fairShareNextWorkerNodeKey (): number | undefined {
+ if (this.pool.workerNodes.length === 0) {
+ return undefined
+ }
return this.pool.workerNodes.reduce(
(minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => {
if (workerNode.strategyData?.virtualTaskEndTimestamp == null) {
workerNodeVirtualTaskStartTimestamp: number
): number {
const workerNodeTaskRunTime =
- this.opts.measurement === Measurements.elu
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.opts!.measurement === Measurements.elu
? this.getWorkerNodeTaskElu(workerNodeKey)
: this.getWorkerNodeTaskRunTime(workerNodeKey)
return workerNodeVirtualTaskStartTimestamp + workerNodeTaskRunTime