repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
docs: refine comment
[poolifier.git]
/
src
/
pools
/
selection-strategies
/
round-robin-worker-choice-strategy.ts
diff --git
a/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts
b/src/pools/selection-strategies/round-robin-worker-choice-strategy.ts
index 41bc4085ebd5a1399975e48e873fc0612c6a611c..7356a0bc2f4b376ef53eb205529cddeddbd0f434 100644
(file)
--- a/
src/pools/selection-strategies/round-robin-worker-choice-strategy.ts
+++ b/
src/pools/selection-strategies/round-robin-worker-choice-strategy.ts
@@
-4,7
+4,6
@@
import type { IWorker } from '../worker'
import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
import type {
IWorkerChoiceStrategy,
import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
import type {
IWorkerChoiceStrategy,
- StrategyPolicy,
WorkerChoiceStrategyOptions
} from './selection-strategies-types'
WorkerChoiceStrategyOptions
} from './selection-strategies-types'
@@
-22,12
+21,6
@@
export class RoundRobinWorkerChoiceStrategy<
>
extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
implements IWorkerChoiceStrategy {
>
extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
implements IWorkerChoiceStrategy {
- /** @inheritDoc */
- public readonly strategyPolicy: StrategyPolicy = {
- dynamicWorkerUsage: false,
- dynamicWorkerReady: true
- }
-
/** @inheritDoc */
public constructor (
pool: IPool<Worker, Data, Response>,
/** @inheritDoc */
public constructor (
pool: IPool<Worker, Data, Response>,
@@
-39,7
+32,7
@@
export class RoundRobinWorkerChoiceStrategy<
/** @inheritDoc */
public reset (): boolean {
/** @inheritDoc */
public reset (): boolean {
- this.
nextWorkerNodeKey = 0
+ this.
resetWorkerNodeKeyProperties()
return true
}
return true
}
@@
-52,9
+45,7
@@
export class RoundRobinWorkerChoiceStrategy<
public choose (): number | undefined {
const chosenWorkerNodeKey = this.nextWorkerNodeKey
this.roundRobinNextWorkerNodeKey()
public choose (): number | undefined {
const chosenWorkerNodeKey = this.nextWorkerNodeKey
this.roundRobinNextWorkerNodeKey()
- if (!this.isWorkerNodeEligible(this.nextWorkerNodeKey as number)) {
- this.nextWorkerNodeKey = undefined
- }
+ this.checkNextWorkerNodeEligibility(chosenWorkerNodeKey)
return chosenWorkerNodeKey
}
return chosenWorkerNodeKey
}
@@
-74,7
+65,7
@@
export class RoundRobinWorkerChoiceStrategy<
this.nextWorkerNodeKey =
this.nextWorkerNodeKey === this.pool.workerNodes.length - 1
? 0
this.nextWorkerNodeKey =
this.nextWorkerNodeKey === this.pool.workerNodes.length - 1
? 0
- : (this.nextWorkerNodeKey ??
0
) + 1
+ : (this.nextWorkerNodeKey ??
this.previousWorkerNodeKey
) + 1
return this.nextWorkerNodeKey
}
}
return this.nextWorkerNodeKey
}
}