feat: add custom worker weights to worker choice strategies options
[poolifier.git] / src / pools / selection-strategies / selection-strategies-types.ts
index 065b310fa5e8a3454f84d5b0edd6324c7c2d0520..0e549cec338b685d36e80ab1ff3d147ef6a3f83f 100644 (file)
@@ -35,8 +35,17 @@ export type WorkerChoiceStrategy = keyof typeof WorkerChoiceStrategies
 export interface WorkerChoiceStrategyOptions {
   /**
    * Use tasks median run time instead of average run time.
+   *
+   * @defaultValue false
    */
   medRunTime?: boolean
+  /**
+   * Worker weights to use for weighted round robin worker selection strategy.
+   * Weight is the tasks maximum average or median runtime in milliseconds.
+   *
+   * @defaultValue Computed worker weights automatically given the CPU performance.
+   */
+  weights?: Record<number, number>
 }
 
 /**
@@ -81,4 +90,10 @@ export interface IWorkerChoiceStrategy {
    * @param workerNodeKey - The worker node key.
    */
   remove: (workerNodeKey: number) => boolean
+  /**
+   * Sets the worker choice strategy options.
+   *
+   * @param opts - The worker choice strategy options.
+   */
+  setOptions: (opts: WorkerChoiceStrategyOptions) => void
 }