Fix WRR worker choice strategy implementation
[poolifier.git] / src / pools / selection-strategies / selection-strategies-types.ts
index edefcfaac429d8c0d24fa897300650d141ab7f3c..4d302f3defb1e7d5619d37693daf4104c944f377 100644 (file)
@@ -11,7 +11,15 @@ export const WorkerChoiceStrategies = Object.freeze({
   /**
    * Less recently used worker selection strategy.
    */
-  LESS_RECENTLY_USED: 'LESS_RECENTLY_USED'
+  LESS_RECENTLY_USED: 'LESS_RECENTLY_USED',
+  /**
+   * Fair share worker selection strategy.
+   */
+  FAIR_SHARE: 'FAIR_SHARE',
+  /**
+   * Weighted round robin worker selection strategy.
+   */
+  WEIGHTED_ROUND_ROBIN: 'WEIGHTED_ROUND_ROBIN'
 } as const)
 
 /**
@@ -19,6 +27,13 @@ export const WorkerChoiceStrategies = Object.freeze({
  */
 export type WorkerChoiceStrategy = keyof typeof WorkerChoiceStrategies
 
+/**
+ * Tasks usage statistics requirements.
+ */
+export type RequiredStatistics = {
+  runTime: boolean
+}
+
 /**
  * Worker choice strategy interface.
  *
@@ -29,6 +44,10 @@ export interface IWorkerChoiceStrategy<Worker extends AbstractPoolWorker> {
    * Is the pool attached to the strategy dynamic?.
    */
   isDynamicPool: boolean
+  /**
+   * Required tasks usage statistics.
+   */
+  requiredStatistics: RequiredStatistics
   /**
    * Choose a worker in the pool.
    */