Merge branch 'master' of github.com:poolifier/poolifier
[poolifier.git] / src / pools / selection-strategies / abstract-worker-choice-strategy.ts
index 31041f3a8783c605d237196f7e89920d04dd27bb..d60d2905674e5b6fc5baa66616a63e9ab9f1fc85 100644 (file)
@@ -1,3 +1,4 @@
+import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils'
 import type { IPoolInternal } from '../pool-internal'
 import { PoolType } from '../pool-internal'
 import type { IWorker } from '../worker'
@@ -36,15 +37,15 @@ export abstract class AbstractWorkerChoiceStrategy<
    */
   public constructor (
     protected readonly pool: IPoolInternal<Worker, Data, Response>,
-    protected readonly opts: WorkerChoiceStrategyOptions = { medRunTime: false }
+    protected readonly opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
   ) {
-    this.checkOptions()
+    this.checkOptions(this.opts)
     this.isDynamicPool = this.pool.type === PoolType.DYNAMIC
     this.choose.bind(this)
   }
 
-  private checkOptions (): void {
-    if (this.requiredStatistics.avgRunTime && this.opts.medRunTime === true) {
+  private checkOptions (opts: WorkerChoiceStrategyOptions): void {
+    if (this.requiredStatistics.avgRunTime && opts.medRunTime === true) {
       this.requiredStatistics.medRunTime = true
     }
   }