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