fix: fix worker choice strategy options handling
[poolifier.git] / src / pools / selection-strategies / less-used-worker-choice-strategy.ts
index 166de7069f60f32d1f396576fd8416e9ba87907d..1138df952a4600b31ff4f60a5540b94f035b31b3 100644 (file)
@@ -1,6 +1,11 @@
+import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils'
+import type { IPool } from '../pool'
 import type { IWorker } from '../worker'
 import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
-import type { IWorkerChoiceStrategy } from './selection-strategies-types'
+import type {
+  IWorkerChoiceStrategy,
+  WorkerChoiceStrategyOptions
+} from './selection-strategies-types'
 
 /**
  * Selects the less used worker.
@@ -16,6 +21,15 @@ export class LessUsedWorkerChoiceStrategy<
   >
   extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
   implements IWorkerChoiceStrategy {
+  /** @inheritDoc */
+  public constructor (
+    pool: IPool<Worker, Data, Response>,
+    opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
+  ) {
+    super(pool, opts)
+    this.checkOptions(opts)
+  }
+
   /** @inheritDoc */
   public reset (): boolean {
     return true