X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fabstract-worker-choice-strategy.ts;h=f1d7dcf405b2e565f150137aa87e4cab1a79bd6d;hb=55d7d6002049be09a06b08da26febe2e8bfa494b;hp=7a64a7e563f9d6d8e1fffdac9ce91d1bc64d5b1e;hpb=97256a852ff3c5a6f85542fe749b831a8c600e30;p=poolifier.git diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index 7a64a7e5..f1d7dcf4 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -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. * @@ -123,7 +128,16 @@ export abstract class AbstractWorkerChoiceStrategy< * @returns Whether the worker node is ready or not. */ protected isWorkerNodeReady (workerNodeKey: number): boolean { - return this.pool.workerNodes[workerNodeKey]?.info.ready ?? false + 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 + } } /**