import crypto from 'node:crypto'
import type { MessageValue, PromiseResponseWrapper } from '../utility-types'
-import { EMPTY_FUNCTION, median } from '../utils'
+import {
+ DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS,
+ EMPTY_FUNCTION,
+ median
+} from '../utils'
import { KillBehaviors, isKillBehavior } from '../worker/worker-options'
import { PoolEvents, type PoolOptions } from './pool'
import { PoolEmitter } from './pool'
opts.workerChoiceStrategy ?? WorkerChoiceStrategies.ROUND_ROBIN
this.checkValidWorkerChoiceStrategy(this.opts.workerChoiceStrategy)
this.opts.workerChoiceStrategyOptions =
- opts.workerChoiceStrategyOptions ?? { medRunTime: false }
+ opts.workerChoiceStrategyOptions ?? DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
this.opts.enableEvents = opts.enableEvents ?? true
this.opts.enableTasksQueue = opts.enableTasksQueue ?? false
}
+import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils'
import type { IPoolInternal } from '../pool-internal'
import { PoolType } from '../pool-internal'
import type { IWorker } from '../worker'
*/
public constructor (
protected readonly pool: IPoolInternal<Worker, Data, Response>,
- protected readonly opts: WorkerChoiceStrategyOptions = { medRunTime: false }
+ protected readonly opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
this.checkOptions(this.opts)
this.isDynamicPool = this.pool.type === PoolType.DYNAMIC
+import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS } from '../../utils'
import type { IPoolInternal } from '../pool-internal'
import type { IWorker } from '../worker'
import { FairShareWorkerChoiceStrategy } from './fair-share-worker-choice-strategy'
public constructor (
pool: IPoolInternal<Worker, Data, Response>,
private workerChoiceStrategyType: WorkerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN,
- opts: WorkerChoiceStrategyOptions = { medRunTime: false }
+ opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
this.execute.bind(this)
this.workerChoiceStrategies = new Map<
+import type { WorkerChoiceStrategyOptions } from './pools/selection-strategies/selection-strategies-types'
+
/**
* An intentional empty function.
*/
})
/**
- * Returns the median of the given data set.
+ * Default worker choice strategy options.
+ */
+export const DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS: WorkerChoiceStrategyOptions =
+ {
+ medRunTime: false
+ }
+
+/**
+ * Compute the median of the given data set.
*
* @param dataSet - Data set.
* @returns The median of the given data set.