}
/** @inheritDoc */
- public readonly taskStatisticsRequirements: TaskStatisticsRequirements = {
- elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
- runTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
- waitTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
- }
+ public readonly taskStatisticsRequirements: TaskStatisticsRequirements =
+ Object.freeze({
+ elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
+ runTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
+ waitTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
+ })
/**
* Constructs a worker choice strategy bound to the pool.
implements IWorkerChoiceStrategy {
/** @inheritDoc */
public override readonly taskStatisticsRequirements: TaskStatisticsRequirements =
- {
+ Object.freeze({
elu: {
aggregate: true,
average: true,
average: true,
median: false,
},
- }
+ })
/** @inheritDoc */
public constructor (
private workerNodeVirtualTaskExecutionTime = 0
/** @inheritDoc */
public override readonly taskStatisticsRequirements: TaskStatisticsRequirements =
- {
+ Object.freeze({
elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
runTime: {
aggregate: true,
average: true,
median: false,
},
- }
+ })
/** @inheritDoc */
public constructor (
implements IWorkerChoiceStrategy {
/** @inheritDoc */
public override readonly taskStatisticsRequirements: TaskStatisticsRequirements =
- {
+ Object.freeze({
elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
runTime: {
aggregate: true,
average: false,
median: false,
},
- }
+ })
/** @inheritDoc */
public constructor (
implements IWorkerChoiceStrategy {
/** @inheritDoc */
public override readonly taskStatisticsRequirements: TaskStatisticsRequirements =
- {
+ Object.freeze({
elu: {
aggregate: true,
average: false,
},
runTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
waitTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
- }
+ })
/** @inheritDoc */
public constructor (
/** @inheritDoc */
public override readonly taskStatisticsRequirements: TaskStatisticsRequirements =
- {
+ Object.freeze({
elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
runTime: {
aggregate: true,
average: true,
median: false,
},
- }
+ })
/** @inheritDoc */
public constructor (
/**
* Default measurement statistics requirements.
*/
-export const DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS: MeasurementStatisticsRequirements =
- {
+export const DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS: Readonly<MeasurementStatisticsRequirements> =
+ Object.freeze({
aggregate: false,
average: false,
median: false,
- }
+ })
export const getDefaultTasksQueueOptions = (
poolMaxSize: number
-): Required<TasksQueueOptions> => {
- return {
+): Required<Readonly<TasksQueueOptions>> => {
+ return Object.freeze({
concurrency: 1,
size: Math.pow(poolMaxSize, 2),
tasksFinishedTimeout: 2000,
tasksStealingOnBackPressure: true,
tasksStealingRatio: 0.6,
taskStealing: true,
- }
+ })
}
export const checkFilePath = (filePath: string | undefined): void => {
import { KillBehaviors, type WorkerOptions } from './worker-options.js'
const DEFAULT_MAX_INACTIVE_TIME = 60000
-const DEFAULT_WORKER_OPTIONS: WorkerOptions = {
+const DEFAULT_WORKER_OPTIONS: Readonly<WorkerOptions> = Object.freeze({
/**
* The kill behavior option on this worker or its default value.
*/
* The pool automatically checks and terminates this worker when the time expires.
*/
maxInactiveTime: DEFAULT_MAX_INACTIVE_TIME,
-}
+})
/**
* Base class that implements some shared logic for all poolifier workers.
/**
* Worker id.
*/
- protected abstract id: number
+ protected abstract readonly id: number
/**
* Timestamp of the last task processed by this worker.
*/
protected readonly isMain: boolean | undefined,
private readonly mainWorker: MainWorker | null | undefined,
taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>,
- protected opts: WorkerOptions = DEFAULT_WORKER_OPTIONS
+ protected readonly opts: WorkerOptions = DEFAULT_WORKER_OPTIONS
) {
if (this.isMain == null) {
throw new Error('isMain parameter is mandatory')