chore: v2.4.9
[poolifier.git] / src / pools / abstract-pool.ts
index f1c6ad13af6ea51de124cfb8545c65e2af5e01e8..7d8531aa8d5d5480f8395f0263c90248f955358d 100644 (file)
@@ -69,7 +69,7 @@ export abstract class AbstractPool<
    * Constructs a new poolifier pool.
    *
    * @param numberOfWorkers - Number of workers that this pool should manage.
-   * @param filePath - Path to the worker-file.
+   * @param filePath - Path to the worker file.
    * @param opts - Options for the pool.
    */
   public constructor (
@@ -216,7 +216,8 @@ export abstract class AbstractPool<
 
   /** @inheritDoc */
   public setWorkerChoiceStrategy (
-    workerChoiceStrategy: WorkerChoiceStrategy
+    workerChoiceStrategy: WorkerChoiceStrategy,
+    workerChoiceStrategyOptions?: WorkerChoiceStrategyOptions
   ): void {
     this.checkValidWorkerChoiceStrategy(workerChoiceStrategy)
     this.opts.workerChoiceStrategy = workerChoiceStrategy
@@ -234,6 +235,9 @@ export abstract class AbstractPool<
     this.workerChoiceStrategyContext.setWorkerChoiceStrategy(
       this.opts.workerChoiceStrategy
     )
+    if (workerChoiceStrategyOptions != null) {
+      this.setWorkerChoiceStrategyOptions(workerChoiceStrategyOptions)
+    }
   }
 
   /** @inheritDoc */
@@ -247,21 +251,25 @@ export abstract class AbstractPool<
   }
 
   /** @inheritDoc */
-  public enableTasksQueue (enable: boolean, opts?: TasksQueueOptions): void {
+  public enableTasksQueue (
+    enable: boolean,
+    tasksQueueOptions?: TasksQueueOptions
+  ): void {
     if (this.opts.enableTasksQueue === true && !enable) {
       for (const [workerNodeKey] of this.workerNodes.entries()) {
         this.flushTasksQueue(workerNodeKey)
       }
     }
     this.opts.enableTasksQueue = enable
-    this.setTasksQueueOptions(opts as TasksQueueOptions)
+    this.setTasksQueueOptions(tasksQueueOptions as TasksQueueOptions)
   }
 
   /** @inheritDoc */
-  public setTasksQueueOptions (opts: TasksQueueOptions): void {
+  public setTasksQueueOptions (tasksQueueOptions: TasksQueueOptions): void {
     if (this.opts.enableTasksQueue === true) {
-      this.checkValidTasksQueueOptions(opts)
-      this.opts.tasksQueueOptions = this.buildTasksQueueOptions(opts)
+      this.checkValidTasksQueueOptions(tasksQueueOptions)
+      this.opts.tasksQueueOptions =
+        this.buildTasksQueueOptions(tasksQueueOptions)
     } else {
       delete this.opts.tasksQueueOptions
     }
@@ -554,7 +562,7 @@ export abstract class AbstractPool<
    * Gets the given worker its tasks usage in the pool.
    *
    * @param worker - The worker.
-   * @throws {@link Error} if the worker is not found in the pool worker nodes.
+   * @throws Error if the worker is not found in the pool worker nodes.
    * @returns The worker tasks usage.
    */
   private getWorkerTasksUsage (worker: Worker): TasksUsage | undefined {