fix: fix worker choice strategy options handling
[poolifier.git] / src / pools / selection-strategies / weighted-round-robin-worker-choice-strategy.ts
index 665022c79aebaf4596e306b7975aa7c0c7f3d923..dc2e5df3f170a1c8d65118e705d6b0754cebf56b 100644 (file)
@@ -7,6 +7,7 @@ import type {
   WorkerChoiceStrategyOptions
 } from './selection-strategies-types'
 import type { IPool } from '../pool'
+import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils'
 
 /**
  * Virtual task runtime.
@@ -54,17 +55,13 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
   TaskRunTime
   >()
 
-  /**
-   * Constructs a worker choice strategy that selects with a weighted round robin scheduling algorithm.
-   *
-   * @param pool - The pool instance.
-   * @param opts - The worker choice strategy options.
-   */
+  /** @inheritDoc */
   public constructor (
     pool: IPool<Worker, Data, Response>,
-    opts?: WorkerChoiceStrategyOptions
+    opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
   ) {
     super(pool, opts)
+    this.checkOptions(opts)
     this.defaultWorkerWeight = this.computeWorkerWeight()
     this.initWorkersTaskRunTime()
   }