X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fworker-choice-strategy-context.ts;h=d8d6f9c4b638fef5305228a22576f84aad7370a8;hb=32e1fcb16c73f8adaea665c21c052ff805f7be60;hp=b7e0a4a7d8d80bc98d55a859cc241f1600bfd41f;hpb=8e8d9101768c28914dabc95c14740985e18f1f04;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 b7e0a4a7..d8d6f9c4 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -29,6 +29,11 @@ export class WorkerChoiceStrategyContext< Data = unknown, Response = unknown > { + /** + * The number of worker choice strategy execution retries. + */ + public retriesCount: number + /** * The worker choice strategy instances registered in the context. */ @@ -38,7 +43,7 @@ export class WorkerChoiceStrategyContext< > /** - * The number of worker choice strategy execution retries. + * The maximum number of worker choice strategy execution retries. */ private readonly retries: number @@ -111,6 +116,7 @@ export class WorkerChoiceStrategyContext< >(pool, opts) ] ]) + this.retriesCount = 0 this.retries = getWorkerChoiceStrategyRetries(pool, opts) } @@ -188,13 +194,11 @@ export class WorkerChoiceStrategyContext< let retriesCount = 0 do { workerNodeKey = workerChoiceStrategy.choose() - if (workerNodeKey != null && workerNodeKey < 0) { - workerNodeKey = undefined - } if (workerNodeKey == null && chooseCount > 0) { - retriesCount++ + ++retriesCount + ++this.retriesCount } - chooseCount++ + ++chooseCount } while (workerNodeKey == null && retriesCount < this.retries) if (workerNodeKey == null) { throw new Error(