refactor: use eslint plugin to sort imports
[poolifier.git] / src / pools / selection-strategies / weighted-round-robin-worker-choice-strategy.ts
index 665022c79aebaf4596e306b7975aa7c0c7f3d923..53b2d64d923412e73ae11f9b8cbc23f892acdf4a 100644 (file)
@@ -1,12 +1,13 @@
 import { cpus } from 'node:os'
 import type { IWorker } from '../worker'
+import type { IPool } from '../pool'
+import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils'
 import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
 import type {
   IWorkerChoiceStrategy,
   RequiredStatistics,
   WorkerChoiceStrategyOptions
 } from './selection-strategies-types'
-import type { IPool } from '../pool'
 
 /**
  * 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(this.opts)
     this.defaultWorkerWeight = this.computeWorkerWeight()
     this.initWorkersTaskRunTime()
   }