From: Jérôme Benoit Date: Tue, 12 Dec 2023 16:33:20 +0000 (+0100) Subject: feat: add infinite retries support in worker choice strategy X-Git-Tag: v3.0.12~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9aa78bcb34d9d6002c71ce3de1ece85dd164871f;p=poolifier.git feat: add infinite retries support in worker choice strategy Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 50747dfe..8a0da774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Add infinite retries support in worker choice strategy. + ## [3.0.11] - 2023-12-11 ### Fixed diff --git a/docs/api.md b/docs/api.md index 28282ac2..4a0a3eb2 100644 --- a/docs/api.md +++ b/docs/api.md @@ -113,7 +113,7 @@ An object with these properties: - `workerChoiceStrategyOptions` (optional) - The worker choice strategy options object to use in this pool. Properties: - - `retries` (optional) - The number of retries to perform if no worker is eligible. + - `retries` (optional) - The number of retries to perform if no worker is eligible. `Infinity` means infinite retries. - `measurement` (optional) - The measurement to use in worker choice strategies: `runTime`, `waitTime` or `elu`. - `runTime` (optional) - Use the tasks [simple moving median](./worker-choice-strategies.md#simple-moving-median) runtime instead of the tasks simple moving average runtime in worker choice strategies. - `waitTime` (optional) - Use the tasks [simple moving median](./worker-choice-strategies.md#simple-moving-median) wait time instead of the tasks simple moving average wait time in worker choice strategies. diff --git a/src/pools/selection-strategies/worker-choice-strategy-context.ts b/src/pools/selection-strategies/worker-choice-strategy-context.ts index e3aaaea3..0ca75e51 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -178,7 +178,8 @@ export class WorkerChoiceStrategyContext< ).choose() if ( workerNodeKey == null && - this.retriesCount < (this.opts.retries as number) + (this.retriesCount < (this.opts.retries as number) || + this.opts.retries === Infinity) ) { this.retriesCount++ return this.execute()