X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fabstract-worker-choice-strategy.ts;h=c2b4d1d3d37b56c5101c235fa2f49cfcfb6bd5fd;hb=df7349e2151c2e46d0bf2c406a5d8bd14d1ed2bf;hp=4ed7dcae2b0dea882d1eb15a1cb0f88310435e7f;hpb=b1aae69557f4f5c524f665e92882b76f23a19866;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..c2b4d1d3 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. */ - protected assignChosenWorkerNodeKey ( + protected checkNextWorkerNodeEligibility ( chosenWorkerNodeKey: number | undefined ): void { - if (chosenWorkerNodeKey != null) { - this.nextWorkerNodeKey = chosenWorkerNodeKey - } else { + if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) { this.nextWorkerNodeKey = undefined + this.previousWorkerNodeKey = + chosenWorkerNodeKey ?? this.previousWorkerNodeKey } }