feat: add initial HTTP/2 support to ui server (mutually exclusive for now)
[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 ConfigurationSection {
12 log = 'log',
13 performanceStorage = 'performanceStorage',
14 worker = 'worker',
15 uiServer = 'uiServer',
16 }
17
18 export enum SupervisionUrlDistribution {
19 ROUND_ROBIN = 'round-robin',
20 RANDOM = 'random',
21 CHARGING_STATION_AFFINITY = 'charging-station-affinity',
22 }
23
24 export interface StationTemplateUrl {
25 file: string;
26 numberOfStations: number;
27 }
28
29 export interface LogConfiguration {
30 enabled?: boolean;
31 file?: string;
32 errorFile?: string;
33 statisticsInterval?: number;
34 level?: string;
35 console?: boolean;
36 format?: string;
37 rotate?: boolean;
38 maxFiles?: string | number;
39 maxSize?: string | number;
40 }
41
42 export enum ApplicationProtocolVersion {
43 VERSION_11 = 1.1,
44 VERSION_20 = 2.0,
45 }
46
47 export interface UIServerConfiguration {
48 enabled?: boolean;
49 type?: ApplicationProtocol;
50 version?: ApplicationProtocolVersion;
51 options?: ServerOptions;
52 authentication?: {
53 enabled: boolean;
54 type: AuthenticationType;
55 username?: string;
56 password?: string;
57 };
58 }
59
60 export interface StorageConfiguration {
61 enabled?: boolean;
62 type?: StorageType;
63 uri?: string;
64 }
65
66 export interface WorkerConfiguration {
67 processType?: WorkerProcessType;
68 startDelay?: number;
69 elementsPerWorker?: number | 'auto';
70 elementStartDelay?: number;
71 poolMinSize?: number;
72 poolMaxSize?: number;
73 /** @deprecated Not publicly exposed to end users. */
74 poolStrategy?: WorkerChoiceStrategy;
75 }
76
77 export interface ConfigurationData {
78 supervisionUrls?: string | string[];
79 supervisionUrlDistribution?: SupervisionUrlDistribution;
80 stationTemplateUrls: StationTemplateUrl[];
81 log?: LogConfiguration;
82 worker?: WorkerConfiguration;
83 uiServer?: UIServerConfiguration;
84 performanceStorage?: StorageConfiguration;
85 autoReconnectMaxRetries?: number;
86 /** @deprecated Moved to worker configuration section. */
87 workerProcess?: WorkerProcessType;
88 /** @deprecated Moved to worker configuration section. */
89 workerStartDelay?: number;
90 /** @deprecated Moved to worker configuration section. */
91 elementStartDelay?: number;
92 /** @deprecated Moved to worker configuration section. */
93 workerPoolMinSize?: number;
94 /** @deprecated Moved to worker configuration section. */
95 workerPoolMaxSize?: number;
96 /** @deprecated Moved to worker configuration section. */
97 workerPoolStrategy?: WorkerChoiceStrategy;
98 /** @deprecated Moved to worker configuration section. */
99 chargingStationsPerWorker?: number;
100 /** @deprecated Moved to log configuration section. */
101 logStatisticsInterval?: number;
102 /** @deprecated Moved to log configuration section. */
103 logEnabled?: boolean;
104 /** @deprecated Moved to log configuration section. */
105 logConsole?: boolean;
106 /** @deprecated Moved to log configuration section. */
107 logFormat?: string;
108 /** @deprecated Moved to log configuration section. */
109 logLevel?: string;
110 /** @deprecated Moved to log configuration section. */
111 logRotate?: boolean;
112 /** @deprecated Moved to log configuration section. */
113 logMaxFiles?: number | string;
114 /** @deprecated Moved to log configuration section. */
115 logMaxSize?: number | string;
116 /** @deprecated Moved to log configuration section. */
117 logFile?: string;
118 /** @deprecated Moved to log configuration section. */
119 logErrorFile?: string;
120 }