X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fleast-elu-worker-choice-strategy.ts;h=c3fe32d144176d88e848a8923fa1eb4b63126f88;hb=cdaecaee1c7fa5c412daf29f2db41470506793ac;hp=81d108a3df6e4006e531ac51d05170fc3748d7f5;hpb=d35e571704515a8b729d3455e4784054f07c368f;p=poolifier.git diff --git a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts index 81d108a3..c3fe32d1 100644 --- a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts @@ -4,8 +4,8 @@ import type { IWorker } from '../worker.js' import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy.js' import type { IWorkerChoiceStrategy, - InternalWorkerChoiceStrategyOptions, - TaskStatisticsRequirements + TaskStatisticsRequirements, + WorkerChoiceStrategyOptions } from './selection-strategies-types.js' /** @@ -36,7 +36,7 @@ export class LeastEluWorkerChoiceStrategy< /** @inheritDoc */ public constructor ( pool: IPool, - opts: InternalWorkerChoiceStrategyOptions + opts?: WorkerChoiceStrategyOptions ) { super(pool, opts) this.setTaskStatisticsRequirements(this.opts) @@ -65,6 +65,9 @@ export class LeastEluWorkerChoiceStrategy< } private leastEluNextWorkerNodeKey (): number | undefined { + if (this.pool.workerNodes.length === 0) { + return undefined + } return this.pool.workerNodes.reduce( (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => { return this.isWorkerNodeReady(workerNodeKey) &&