repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/fastify-worker_thr...
[poolifier.git]
/
src
/
pools
/
selection-strategies
/
fair-share-worker-choice-strategy.ts
diff --git
a/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts
b/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts
index 36d1cd4c407c89de4231911bd22cb57b23350781..c4a0d30beb7fe827d614ca9f434c7470aeb9d018 100644
(file)
--- a/
src/pools/selection-strategies/fair-share-worker-choice-strategy.ts
+++ b/
src/pools/selection-strategies/fair-share-worker-choice-strategy.ts
@@
-69,8
+69,10
@@
export class FairShareWorkerChoiceStrategy<
}
/** @inheritDoc */
}
/** @inheritDoc */
- public choose (): number {
- return this.fairShareNextWorkerNodeKey()
+ public choose (): number | undefined {
+ this.setPreviousWorkerNodeKey(this.nextWorkerNodeKey)
+ this.nextWorkerNodeKey = this.fairShareNextWorkerNodeKey()
+ return this.nextWorkerNodeKey
}
/** @inheritDoc */
}
/** @inheritDoc */
@@
-79,7
+81,8
@@
export class FairShareWorkerChoiceStrategy<
return true
}
return true
}
- private fairShareNextWorkerNodeKey (): number {
+ private fairShareNextWorkerNodeKey (): number | undefined {
+ let chosenWorkerNodeKey: number | undefined
let minWorkerVirtualTaskEndTimestamp = Infinity
for (const [workerNodeKey] of this.pool.workerNodes.entries()) {
if (this.workersVirtualTaskEndTimestamp[workerNodeKey] == null) {
let minWorkerVirtualTaskEndTimestamp = Infinity
for (const [workerNodeKey] of this.pool.workerNodes.entries()) {
if (this.workersVirtualTaskEndTimestamp[workerNodeKey] == null) {
@@
-87,15
+90,12
@@
export class FairShareWorkerChoiceStrategy<
}
const workerVirtualTaskEndTimestamp =
this.workersVirtualTaskEndTimestamp[workerNodeKey]
}
const workerVirtualTaskEndTimestamp =
this.workersVirtualTaskEndTimestamp[workerNodeKey]
- if (
- this.isWorkerNodeEligible(workerNodeKey) &&
- workerVirtualTaskEndTimestamp < minWorkerVirtualTaskEndTimestamp
- ) {
+ if (workerVirtualTaskEndTimestamp < minWorkerVirtualTaskEndTimestamp) {
minWorkerVirtualTaskEndTimestamp = workerVirtualTaskEndTimestamp
minWorkerVirtualTaskEndTimestamp = workerVirtualTaskEndTimestamp
-
this.next
WorkerNodeKey = workerNodeKey
+
chosen
WorkerNodeKey = workerNodeKey
}
}
}
}
- return
this.next
WorkerNodeKey
+ return
chosen
WorkerNodeKey
}
/**
}
/**