- public choose (): Worker {
- const chosenWorker = this.pool.workers[this.nextWorkerIndex]
- this.nextWorkerIndex =
- this.nextWorkerIndex === this.pool.workers.length - 1
+ public constructor (
+ pool: IPool<Worker, Data, Response>,
+ opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
+ ) {
+ super(pool, opts)
+ this.checkOptions(this.opts)
+ }
+
+ /** @inheritDoc */
+ public reset (): boolean {
+ this.nextWorkerNodeId = 0
+ return true
+ }
+
+ /** @inheritDoc */
+ public choose (): number {
+ const chosenWorkerNodeKey = this.nextWorkerNodeId
+ this.nextWorkerNodeId =
+ this.nextWorkerNodeId === this.pool.workerNodes.length - 1