X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fworker-choice-strategy-context.ts;h=40e2e18f303122685c70eb09e824175ab5309cef;hb=61ee03c80d4de04751bf0218d9574bbd8c94e159;hp=9e18fdc4315fc322f7aabc5e49c92bdaa3a46767;hpb=0268f52c63db50bc10eeef8d7117627b44726878;p=poolifier.git diff --git a/src/pools/selection-strategies/worker-choice-strategy-context.ts b/src/pools/selection-strategies/worker-choice-strategy-context.ts index 9e18fdc4..40e2e18f 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -166,17 +166,13 @@ export class WorkerChoiceStrategyContext< * Executes the worker choice strategy in the context algorithm. * * @returns The key of the worker node. - * @throws {@link https://nodejs.org/api/errors.html#class-error} If after configured retries the worker node key is null or undefined. + * @throws {@link https://nodejs.org/api/errors.html#class-error} If after computed retries the worker node key is null or undefined. */ public execute (): number { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const workerChoiceStrategy = this.workerChoiceStrategies.get( - this.workerChoiceStrategy - )! - if (!workerChoiceStrategy.hasPoolWorkerNodesReady()) { - return this.execute() - } - return this.executeStrategy(workerChoiceStrategy) + return this.executeStrategy( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + this.workerChoiceStrategies.get(this.workerChoiceStrategy)! + ) } /** @@ -184,7 +180,7 @@ export class WorkerChoiceStrategyContext< * * @param workerChoiceStrategy - The worker choice strategy. * @returns The key of the worker node. - * @throws {@link https://nodejs.org/api/errors.html#class-error} If after configured retries the worker node key is null or undefined. + * @throws {@link https://nodejs.org/api/errors.html#class-error} If after computed retries the worker node key is null or undefined. */ private executeStrategy (workerChoiceStrategy: IWorkerChoiceStrategy): number { let workerNodeKey: number | undefined