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>,
/** @inheritDoc */
public reset (): boolean {
- this.nextWorkerNodeKey = 0
+ this.resetWorkerNodeKeyProperties()
return true
}
public choose (): number | undefined {
const chosenWorkerNodeKey = this.nextWorkerNodeKey
this.roundRobinNextWorkerNodeKey()
- if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) {
- this.nextWorkerNodeKey = undefined
- this.previousWorkerNodeKey =
- chosenWorkerNodeKey ?? this.previousWorkerNodeKey
- }
+ this.checkNextWorkerNodeEligibility(chosenWorkerNodeKey)
return chosenWorkerNodeKey
}