import type { IPool } from '../pool'
import type { IWorker } from '../worker'
import { FairShareWorkerChoiceStrategy } from './fair-share-worker-choice-strategy'
+import { InterleavedWeightedRoundRobinWorkerChoiceStrategy } from './interleaved-weighted-round-robin-worker-choice-strategy'
import { LessBusyWorkerChoiceStrategy } from './less-busy-worker-choice-strategy'
import { LessUsedWorkerChoiceStrategy } from './less-used-worker-choice-strategy'
import { RoundRobinWorkerChoiceStrategy } from './round-robin-worker-choice-strategy'
Data,
Response
>(pool, opts)
+ ],
+ [
+ WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN,
+ new (InterleavedWeightedRoundRobinWorkerChoiceStrategy.bind(this))<
+ Worker,
+ Data,
+ Response
+ >(pool, opts)
]
])
}
* Executes the worker choice strategy algorithm in the context.
*
* @returns The key of the worker node.
- * @throws {@link Error} If the worker node key is null or undefined.
+ * @throws {@link https://nodejs.org/api/errors.html#class-error} If the worker node key is null or undefined.
*/
public execute (): number {
const workerNodeKey = (
* @param opts - The worker choice strategy options.
*/
public setOptions (opts: WorkerChoiceStrategyOptions): void {
- this.workerChoiceStrategies.forEach(workerChoiceStrategy => {
+ for (const workerChoiceStrategy of this.workerChoiceStrategies.values()) {
workerChoiceStrategy.setOptions(opts)
- })
+ }
}
}