docs: refine worker choice strategies README
[poolifier.git] / src / pools / selection-strategies / selection-strategies-types.ts
index c578ddc3f9fb24e289f5caf8fa542ec402d63834..7a5a10c6018fda998f61143c42b47fb9bd4d8e41 100644 (file)
@@ -41,10 +41,24 @@ export const WorkerChoiceStrategies = Object.freeze({
  */
 export type WorkerChoiceStrategy = keyof typeof WorkerChoiceStrategies
 
+/**
+ * Enumeration of measurements.
+ */
+export const Measurements = Object.freeze({
+  runTime: 'runTime',
+  waitTime: 'waitTime',
+  elu: 'elu'
+} as const)
+
+/**
+ * Measurement.
+ */
+export type Measurement = keyof typeof Measurements
+
 /**
  * Measurement options.
  */
-interface MeasurementOptions {
+export interface MeasurementOptions {
   /**
    * Set measurement median.
    */
@@ -55,6 +69,10 @@ interface MeasurementOptions {
  * Worker choice strategy options.
  */
 export interface WorkerChoiceStrategyOptions {
+  /**
+   * Measurement to use for worker choice strategy.
+   */
+  measurement?: Measurement
   /**
    * Runtime options.
    *
@@ -87,7 +105,7 @@ export interface WorkerChoiceStrategyOptions {
  *
  * @internal
  */
-interface MeasurementStatisticsRequirements {
+export interface MeasurementStatisticsRequirements {
   /**
    * Require measurement aggregate.
    */
@@ -122,10 +140,26 @@ export interface TaskStatisticsRequirements {
   elu: MeasurementStatisticsRequirements
 }
 
+/**
+ * Strategy policy.
+ *
+ * @internal
+ */
+export interface StrategyPolicy {
+  /**
+   * Expect direct usage of dynamic worker.
+   */
+  useDynamicWorker: boolean
+}
+
 /**
  * Worker choice strategy interface.
  */
 export interface IWorkerChoiceStrategy {
+  /**
+   * Strategy policy.
+   */
+  readonly strategyPolicy: StrategyPolicy
   /**
    * Tasks statistics requirements.
    */