docs: add changelog entry
[poolifier.git] / src / pools / selection-strategies / abstract-worker-choice-strategy.ts
index 86692de92f50c6cc9b1c1c7bcb3e1e960d5693e5..f1d7dcf405b2e565f150137aa87e4cab1a79bd6d 100644 (file)
@@ -116,6 +116,11 @@ export abstract class AbstractWorkerChoiceStrategy<
     this.setTaskStatisticsRequirements(this.opts)
   }
 
+  /** @inheritDoc */
+  public hasPoolWorkerNodesReady (): boolean {
+    return this.pool.workerNodes.some(workerNode => workerNode.info.ready)
+  }
+
   /**
    * Whether the worker node is ready or not.
    *
@@ -126,6 +131,15 @@ export abstract class AbstractWorkerChoiceStrategy<
     return this.pool.workerNodes[workerNodeKey]?.info?.ready ?? false
   }
 
+  /**
+   * Check the next worker node readiness.
+   */
+  protected checkNextWorkerNodeReadiness (): void {
+    if (!this.isWorkerNodeReady(this.nextWorkerNodeKey as number)) {
+      delete this.nextWorkerNodeKey
+    }
+  }
+
   /**
    * Gets the worker node task runtime.
    * If the task statistics require the average runtime, the average runtime is returned.