Merge branch 'master' into combine-prs-branch
[poolifier.git] / src / pools / selection-strategies / round-robin-worker-choice-strategy.ts
index 7a50db7b6387d5426dd4c4847482c5314f611b74..7356a0bc2f4b376ef53eb205529cddeddbd0f434 100644 (file)
@@ -32,7 +32,7 @@ export class RoundRobinWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public reset (): boolean {
-    this.nextWorkerNodeKey = 0
+    this.resetWorkerNodeKeyProperties()
     return true
   }
 
@@ -45,11 +45,7 @@ export class RoundRobinWorkerChoiceStrategy<
   public choose (): number | undefined {
     const chosenWorkerNodeKey = this.nextWorkerNodeKey
     this.roundRobinNextWorkerNodeKey()
-    if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) {
-      this.nextWorkerNodeKey = undefined
-      this.previousWorkerNodeKey =
-        chosenWorkerNodeKey ?? this.previousWorkerNodeKey
-    }
+    this.checkNextWorkerNodeEligibility(chosenWorkerNodeKey)
     return chosenWorkerNodeKey
   }