X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=src%2Fpools%2Fselection-strategies%2Fabstract-worker-choice-strategy.ts;h=2fba4e9fbd1a17be10fd9d6a86a6cb574a9ad03b;hb=9fe8fd698590c2494dc6793cfd8c08026fe88a31;hp=4ed7dcae2b0dea882d1eb15a1cb0f88310435e7f;hpb=936fa0fb8e70b2c297938cc9455444486b6daa3e;p=poolifier.git diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index 4ed7dcae..2fba4e9f 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -30,10 +30,15 @@ export abstract class AbstractWorkerChoiceStrategy< */ protected nextWorkerNodeKey: number | undefined = 0 + /** + * The previous worker node key. + */ + protected previousWorkerNodeKey: number = 0 + /** @inheritDoc */ public readonly strategyPolicy: StrategyPolicy = { dynamicWorkerUsage: false, - dynamicWorkerReady: false + dynamicWorkerReady: true } /** @inheritDoc */ @@ -88,6 +93,11 @@ export abstract class AbstractWorkerChoiceStrategy< } } + protected resetWorkerNodeKeyProperties (): void { + this.nextWorkerNodeKey = 0 + this.previousWorkerNodeKey = 0 + } + /** @inheritDoc */ public abstract reset (): boolean @@ -185,17 +195,17 @@ export abstract class AbstractWorkerChoiceStrategy< } /** - * Assign to nextWorkerNodeKey property the chosen worker node key. + * Check the next worker node eligibility. * - * @param chosenWorkerNodeKey - The chosen worker node key. + * @param chosenNextWorkerNodeKey - The chosen worker node key. */ - protected assignChosenWorkerNodeKey ( - chosenWorkerNodeKey: number | undefined + protected checkNextWorkerNodeEligibility ( + chosenNextWorkerNodeKey: number | undefined ): void { - if (chosenWorkerNodeKey != null) { - this.nextWorkerNodeKey = chosenWorkerNodeKey - } else { + if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) { this.nextWorkerNodeKey = undefined + this.previousWorkerNodeKey = + chosenNextWorkerNodeKey ?? this.previousWorkerNodeKey } }