+ this.execute = this.execute.bind(this)
+ this.workerChoiceStrategies = new Map<
+ WorkerChoiceStrategy,
+ IWorkerChoiceStrategy
+ >([
+ [
+ WorkerChoiceStrategies.ROUND_ROBIN,
+ new (RoundRobinWorkerChoiceStrategy.bind(this))<Worker, Data, Response>(
+ pool,
+ opts
+ )
+ ],
+ [
+ WorkerChoiceStrategies.LEAST_USED,
+ new (LeastUsedWorkerChoiceStrategy.bind(this))<Worker, Data, Response>(
+ pool,
+ opts
+ )
+ ],
+ [
+ WorkerChoiceStrategies.LEAST_BUSY,
+ new (LeastBusyWorkerChoiceStrategy.bind(this))<Worker, Data, Response>(
+ pool,
+ opts
+ )
+ ],
+ [
+ WorkerChoiceStrategies.LEAST_ELU,
+ new (LeastEluWorkerChoiceStrategy.bind(this))<Worker, Data, Response>(
+ pool,
+ opts
+ )
+ ],
+ [
+ WorkerChoiceStrategies.FAIR_SHARE,
+ new (FairShareWorkerChoiceStrategy.bind(this))<Worker, Data, Response>(
+ pool,
+ opts
+ )
+ ],
+ [
+ WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN,
+ new (WeightedRoundRobinWorkerChoiceStrategy.bind(this))<
+ Worker,
+ Data,
+ Response
+ >(pool, opts)
+ ],
+ [
+ WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN,
+ new (InterleavedWeightedRoundRobinWorkerChoiceStrategy.bind(this))<
+ Worker,
+ Data,
+ Response
+ >(pool, opts)
+ ]
+ ])
+ this.retriesCount = 0
+ this.retries = getWorkerChoiceStrategyRetries(pool, opts)
+ }
+
+ /**
+ * Gets the strategy policy in the context.
+ *
+ * @returns The strategy policy.
+ */
+ public getStrategyPolicy (): StrategyPolicy {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ return this.workerChoiceStrategies.get(this.workerChoiceStrategy)!
+ .strategyPolicy