From 9aa78bcb34d9d6002c71ce3de1ece85dd164871f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 12 Dec 2023 17:33:20 +0100 Subject: [PATCH] feat: add infinite retries support in worker choice strategy MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 4 ++++ docs/api.md | 2 +- .../selection-strategies/worker-choice-strategy-context.ts | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) 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() -- 2.34.1