feat: allow to provision number of stations by template
[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 provisionedNumberOfStations?: number
29 }
30
31 export interface LogConfiguration {
32 enabled?: boolean
33 file?: string
34 errorFile?: string
35 statisticsInterval?: number
36 level?: string
37 console?: boolean
38 format?: string
39 rotate?: boolean
40 maxFiles?: string | number
41 maxSize?: string | number
42 }
43
44 export enum ApplicationProtocolVersion {
45 VERSION_11 = 1.1,
46 VERSION_20 = 2.0
47 }
48
49 export interface UIServerConfiguration {
50 enabled?: boolean
51 type?: ApplicationProtocol
52 version?: ApplicationProtocolVersion
53 options?: ServerOptions
54 authentication?: {
55 enabled: boolean
56 type: AuthenticationType
57 username?: string
58 password?: string
59 }
60 }
61
62 export interface StorageConfiguration {
63 enabled?: boolean
64 type?: StorageType
65 uri?: string
66 }
67
68 export type ElementsPerWorkerType = number | 'auto' | 'all'
69
70 export interface WorkerConfiguration {
71 processType?: WorkerProcessType
72 startDelay?: number
73 elementsPerWorker?: ElementsPerWorkerType
74 /** @deprecated Use `elementAddDelay` instead. */
75 elementStartDelay?: number
76 elementAddDelay?: number
77 poolMinSize?: number
78 poolMaxSize?: number
79 resourceLimits?: ResourceLimits
80 }
81
82 export interface ConfigurationData {
83 supervisionUrls?: string | string[]
84 supervisionUrlDistribution?: SupervisionUrlDistribution
85 stationTemplateUrls: StationTemplateUrl[]
86 log?: LogConfiguration
87 worker?: WorkerConfiguration
88 uiServer?: UIServerConfiguration
89 performanceStorage?: StorageConfiguration
90 /** @deprecated Moved to charging station template. */
91 autoReconnectMaxRetries?: number
92 /** @deprecated Moved to worker configuration section. */
93 workerProcess?: WorkerProcessType
94 /** @deprecated Moved to worker configuration section. */
95 workerStartDelay?: number
96 /** @deprecated Moved to worker configuration section. */
97 elementAddDelay?: number
98 /** @deprecated Moved to worker configuration section. */
99 workerPoolMinSize?: number
100 /** @deprecated Moved to worker configuration section. */
101 workerPoolMaxSize?: number
102 /** @deprecated Moved to worker configuration section. */
103 workerPoolStrategy?: WorkerChoiceStrategy
104 /** @deprecated Moved to worker configuration section. */
105 chargingStationsPerWorker?: number
106 /** @deprecated Moved to log configuration section. */
107 logStatisticsInterval?: number
108 /** @deprecated Moved to log configuration section. */
109 logEnabled?: boolean
110 /** @deprecated Moved to log configuration section. */
111 logConsole?: boolean
112 /** @deprecated Moved to log configuration section. */
113 logFormat?: string
114 /** @deprecated Moved to log configuration section. */
115 logLevel?: string
116 /** @deprecated Moved to log configuration section. */
117 logRotate?: boolean
118 /** @deprecated Moved to log configuration section. */
119 logMaxFiles?: number | string
120 /** @deprecated Moved to log configuration section. */
121 logMaxSize?: number | string
122 /** @deprecated Moved to log configuration section. */
123 logFile?: string
124 /** @deprecated Moved to log configuration section. */
125 logErrorFile?: string
126 }