X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fleast-elu-worker-choice-strategy.ts;h=5df742a665d5d9b5ed838beb887e426da43ade07;hb=5ea80606520ed06f815f4f7485ec9057ac23b176;hp=35ab69d0ca38595c2f81be566a0b7352bf900e4e;hpb=5df69fabd77b3ec4137a6382e2d84791bf0fe85d;p=poolifier.git diff --git a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts index 35ab69d0..5df742a6 100644 --- a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts @@ -57,24 +57,24 @@ export class LeastEluWorkerChoiceStrategy< /** @inheritDoc */ public update (): boolean { - return true - } - - /** @inheritDoc */ - public choose (): number { let minWorkerElu = Infinity - let leastEluWorkerNodeKey!: number for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) { const workerUsage = workerNode.workerUsage const workerElu = workerUsage.elu?.active.aggregate ?? 0 if (workerElu === 0) { - return workerNodeKey + this.nextWorkerNodeId = workerNodeKey + break } else if (workerElu < minWorkerElu) { minWorkerElu = workerElu - leastEluWorkerNodeKey = workerNodeKey + this.nextWorkerNodeId = workerNodeKey } } - return leastEluWorkerNodeKey + return true + } + + /** @inheritDoc */ + public choose (): number { + return this.nextWorkerNodeId } /** @inheritDoc */