chore(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git] / src / worker / WorkerConstants.ts
CommitLineData
66a7748d 1import { availableParallelism } from 'poolifier'
60d1f5b0 2
66a7748d 3import type { WorkerOptions } from './WorkerTypes.js'
0749233f 4
66a7748d 5import { defaultErrorHandler, defaultExitHandler } from './WorkerUtils.js'
59b6ed8d 6
769d3b10
JB
7export const EMPTY_FUNCTION = Object.freeze(() => {
8 /* This is intentional */
66a7748d 9})
4db8406c 10
66a7748d 11export const workerSetVersion = '1.0.1'
628c30e5 12
da47bc29 13export const DEFAULT_ELEMENT_ADD_DELAY = 0
66a7748d
JB
14export const DEFAULT_WORKER_START_DELAY = 500
15export const DEFAULT_POOL_MIN_SIZE = Math.floor(availableParallelism() / 2)
16export const DEFAULT_POOL_MAX_SIZE = Math.round(availableParallelism() * 1.5)
17export const DEFAULT_ELEMENTS_PER_WORKER = 1
769d3b10
JB
18
19export const DEFAULT_WORKER_OPTIONS: WorkerOptions = Object.freeze({
da47bc29 20 elementAddDelay: DEFAULT_ELEMENT_ADD_DELAY,
769d3b10 21 elementsPerWorker: DEFAULT_ELEMENTS_PER_WORKER,
0749233f
JB
22 poolMaxSize: DEFAULT_POOL_MAX_SIZE,
23 poolMinSize: DEFAULT_POOL_MIN_SIZE,
c81424b8
JB
24 poolOptions: {
25 enableEvents: true,
66a7748d 26 errorHandler: defaultErrorHandler,
d1f5bfd8 27 exitHandler: defaultExitHandler,
0749233f
JB
28 restartWorkerOnError: true,
29 startWorkers: false,
d1f5bfd8 30 },
0749233f 31 workerStartDelay: DEFAULT_WORKER_START_DELAY,
66a7748d 32})