feat: add elementsPerWorker automatic calculation
[e-mobility-charging-stations-simulator.git] / src / types / ConfigurationData.ts
1 import type { ListenOptions } from 'node:net';
2
3 import type { WorkerChoiceStrategy } from 'poolifier';
4
5 import type { StorageType } from './Storage';
6 import type { ApplicationProtocol, AuthenticationType } from './UIProtocol';
7 import type { WorkerProcessType } from '../worker';
8
9 type ServerOptions = ListenOptions;
10
11 export enum SupervisionUrlDistribution {
12 ROUND_ROBIN = 'round-robin',
13 RANDOM = 'random',
14 CHARGING_STATION_AFFINITY = 'charging-station-affinity',
15 }
16
17 export type StationTemplateUrl = {
18 file: string;
19 numberOfStations: number;
20 };
21
22 export type LogConfiguration = {
23 enabled?: boolean;
24 file?: string;
25 errorFile?: string;
26 statisticsInterval?: number;
27 level?: string;
28 console?: boolean;
29 format?: string;
30 rotate?: boolean;
31 maxFiles?: string | number;
32 maxSize?: string | number;
33 };
34
35 export type UIServerConfiguration = {
36 enabled?: boolean;
37 type?: ApplicationProtocol;
38 options?: ServerOptions;
39 authentication?: {
40 enabled: boolean;
41 type: AuthenticationType;
42 username?: string;
43 password?: string;
44 };
45 };
46
47 export type StorageConfiguration = {
48 enabled?: boolean;
49 type?: StorageType;
50 uri?: string;
51 };
52
53 export type WorkerConfiguration = {
54 processType?: WorkerProcessType;
55 startDelay?: number;
56 elementsPerWorker?: number | 'auto';
57 elementStartDelay?: number;
58 poolMinSize?: number;
59 poolMaxSize?: number;
60 poolStrategy?: WorkerChoiceStrategy;
61 };
62
63 export type ConfigurationData = {
64 supervisionUrls?: string | string[];
65 supervisionUrlDistribution?: SupervisionUrlDistribution;
66 stationTemplateUrls: StationTemplateUrl[];
67 log?: LogConfiguration;
68 worker?: WorkerConfiguration;
69 uiServer?: UIServerConfiguration;
70 performanceStorage?: StorageConfiguration;
71 autoReconnectMaxRetries?: number;
72 /** @deprecated Moved to worker configuration section. */
73 workerProcess?: WorkerProcessType;
74 /** @deprecated Moved to worker configuration section. */
75 workerStartDelay?: number;
76 /** @deprecated Moved to worker configuration section. */
77 elementStartDelay?: number;
78 /** @deprecated Moved to worker configuration section. */
79 workerPoolMinSize?: number;
80 /** @deprecated Moved to worker configuration section. */
81 workerPoolMaxSize?: number;
82 /** @deprecated Moved to worker configuration section. */
83 workerPoolStrategy?: WorkerChoiceStrategy;
84 /** @deprecated Moved to worker configuration section. */
85 chargingStationsPerWorker?: number;
86 /** @deprecated Moved to log configuration section. */
87 logStatisticsInterval?: number;
88 /** @deprecated Moved to log configuration section. */
89 logEnabled?: boolean;
90 /** @deprecated Moved to log configuration section. */
91 logConsole?: boolean;
92 /** @deprecated Moved to log configuration section. */
93 logFormat?: string;
94 /** @deprecated Moved to log configuration section. */
95 logLevel?: string;
96 /** @deprecated Moved to log configuration section. */
97 logRotate?: boolean;
98 /** @deprecated Moved to log configuration section. */
99 logMaxFiles?: number | string;
100 /** @deprecated Moved to log configuration section. */
101 logMaxSize?: number | string;
102 /** @deprecated Moved to log configuration section. */
103 logFile?: string;
104 /** @deprecated Moved to log configuration section. */
105 logErrorFile?: string;
106 };