}
}
+ protected checkNextWorkerNodeEligibility (
+ chosenWorkerNodeKey: number | undefined
+ ): void {
+ if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) {
+ this.nextWorkerNodeKey = undefined
+ this.previousWorkerNodeKey =
+ chosenWorkerNodeKey ?? this.previousWorkerNodeKey
+ }
+ }
+
protected computeDefaultWorkerWeight (): number {
let cpusCycleTimeWeight = 0
for (const cpu of cpus()) {
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
}
public choose (): number | undefined {
const chosenWorkerNodeKey = this.nextWorkerNodeKey
this.weightedRoundRobinNextWorkerNodeKey()
- if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) {
- this.nextWorkerNodeKey = undefined
- this.previousWorkerNodeKey =
- chosenWorkerNodeKey ?? this.previousWorkerNodeKey
- }
+ this.checkNextWorkerNodeEligibility(chosenWorkerNodeKey)
return chosenWorkerNodeKey
}