import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
import type {
IWorkerChoiceStrategy,
- StrategyPolicy,
WorkerChoiceStrategyOptions
} from './selection-strategies-types'
>
extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
implements IWorkerChoiceStrategy {
- /** @inheritDoc */
- public readonly strategyPolicy: StrategyPolicy = {
- dynamicWorkerUsage: false,
- dynamicWorkerReady: true
- }
-
/** @inheritDoc */
public constructor (
pool: IPool<Worker, Data, Response>,
this.roundRobinNextWorkerNodeKey()
if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) {
this.nextWorkerNodeKey = undefined
+ this.previousWorkerNodeKey =
+ chosenWorkerNodeKey ?? this.previousWorkerNodeKey
}
return chosenWorkerNodeKey
}
this.nextWorkerNodeKey =
this.nextWorkerNodeKey === this.pool.workerNodes.length - 1
? 0
- : (this.nextWorkerNodeKey ?? 0) + 1
+ : (this.nextWorkerNodeKey ?? this.previousWorkerNodeKey) + 1
return this.nextWorkerNodeKey
}
}