repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
perf: properly bound methods in hot paths
[e-mobility-charging-stations-simulator.git]
/
src
/
utils
/
Configuration.ts
diff --git
a/src/utils/Configuration.ts
b/src/utils/Configuration.ts
index 6f1705a69b813082cd62e2850153a357374d1337..8c3d15ccbdde967cb0051f9dab2cd36f5c5d9c7f 100644
(file)
--- a/
src/utils/Configuration.ts
+++ b/
src/utils/Configuration.ts
@@
-6,7
+6,10
@@
import chalk from 'chalk';
import merge from 'just-merge';
import { WorkerChoiceStrategies } from 'poolifier';
import merge from 'just-merge';
import { WorkerChoiceStrategies } from 'poolifier';
-import { Constants, FileUtils, Utils } from './internal';
+// import { Constants, FileUtils, Utils } from './internal';
+import { Constants } from './Constants';
+import { FileUtils } from './FileUtils';
+import { Utils } from './Utils';
import {
ApplicationProtocol,
type ConfigurationData,
import {
ApplicationProtocol,
type ConfigurationData,
@@
-46,13
+49,13
@@
export class Configuration {
"Use 'logStatisticsInterval' instead"
);
// Read conf
"Use 'logStatisticsInterval' instead"
);
// Read conf
- return Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'logStatisticsInterval')
+ return Utils.
hasOwnProp
(Configuration.getConfig(), 'logStatisticsInterval')
? Configuration.getConfig()?.logStatisticsInterval
: Constants.DEFAULT_LOG_STATISTICS_INTERVAL;
}
static getUIServer(): UIServerConfiguration {
? Configuration.getConfig()?.logStatisticsInterval
: Constants.DEFAULT_LOG_STATISTICS_INTERVAL;
}
static getUIServer(): UIServerConfiguration {
- if (Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'uiWebSocketServer')) {
+ if (Utils.
hasOwnProp
(Configuration.getConfig(), 'uiWebSocketServer')) {
console.error(
chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration section 'uiWebSocketServer' usage. Use 'uiServer' instead}`
);
console.error(
chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration section 'uiWebSocketServer' usage. Use 'uiServer' instead}`
);
@@
-65,7
+68,7
@@
export class Configuration {
port: Constants.DEFAULT_UI_SERVER_PORT,
},
};
port: Constants.DEFAULT_UI_SERVER_PORT,
},
};
- if (Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'uiServer')) {
+ if (Utils.
hasOwnProp
(Configuration.getConfig(), 'uiServer')) {
uiServerConfiguration = merge<UIServerConfiguration>(
uiServerConfiguration,
Configuration.getConfig()?.uiServer
uiServerConfiguration = merge<UIServerConfiguration>(
uiServerConfiguration,
Configuration.getConfig()?.uiServer
@@
-85,7
+88,7
@@
export class Configuration {
type: StorageType.JSON_FILE,
uri: this.getDefaultPerformanceStorageUri(StorageType.JSON_FILE),
};
type: StorageType.JSON_FILE,
uri: this.getDefaultPerformanceStorageUri(StorageType.JSON_FILE),
};
- if (Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'performanceStorage')) {
+ if (Utils.
hasOwnProp
(Configuration.getConfig(), 'performanceStorage')) {
storageConfiguration = {
...storageConfiguration,
...Configuration.getConfig()?.performanceStorage,
storageConfiguration = {
...storageConfiguration,
...Configuration.getConfig()?.performanceStorage,
@@
-111,7
+114,7
@@
export class Configuration {
'Use it in charging station template instead'
);
// Read conf
'Use it in charging station template instead'
);
// Read conf
- if (Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'autoReconnectMaxRetries')) {
+ if (Utils.
hasOwnProp
(Configuration.getConfig(), 'autoReconnectMaxRetries')) {
return Configuration.getConfig()?.autoReconnectMaxRetries;
}
}
return Configuration.getConfig()?.autoReconnectMaxRetries;
}
}
@@
-125,7
+128,7
@@
export class Configuration {
!Utils.isUndefined(Configuration.getConfig()['stationTemplateURLs']) &&
(Configuration.getConfig().stationTemplateUrls = Configuration.getConfig()[
'stationTemplateURLs'
!Utils.isUndefined(Configuration.getConfig()['stationTemplateURLs']) &&
(Configuration.getConfig().stationTemplateUrls = Configuration.getConfig()[
'stationTemplateURLs'
- ] as
unknown as
StationTemplateUrl[]);
+ ] as StationTemplateUrl[]);
Configuration.getConfig().stationTemplateUrls.forEach((stationUrl: StationTemplateUrl) => {
if (!Utils.isUndefined(stationUrl['numberOfStation'])) {
console.error(
Configuration.getConfig().stationTemplateUrls.forEach((stationUrl: StationTemplateUrl) => {
if (!Utils.isUndefined(stationUrl['numberOfStation'])) {
console.error(
@@
-186,31
+189,28
@@
export class Configuration {
"Use 'worker' section to define the worker pool strategy instead"
);
let workerConfiguration: WorkerConfiguration = {
"Use 'worker' section to define the worker pool strategy instead"
);
let workerConfiguration: WorkerConfiguration = {
- processType: Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'workerProcess')
+ processType: Utils.
hasOwnProp
(Configuration.getConfig(), 'workerProcess')
? Configuration.getConfig()?.workerProcess
? Configuration.getConfig()?.workerProcess
- : WorkerProcessType.
WORKER_SET
,
- startDelay: Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'workerStartDelay')
+ : WorkerProcessType.
workerSet
,
+ startDelay: Utils.
hasOwnProp
(Configuration.getConfig(), 'workerStartDelay')
? Configuration.getConfig()?.workerStartDelay
: WorkerConstants.DEFAULT_WORKER_START_DELAY,
? Configuration.getConfig()?.workerStartDelay
: WorkerConstants.DEFAULT_WORKER_START_DELAY,
- elementsPerWorker: Utils.objectHasOwnProperty(
- Configuration.getConfig(),
- 'chargingStationsPerWorker'
- )
+ elementsPerWorker: Utils.hasOwnProp(Configuration.getConfig(), 'chargingStationsPerWorker')
? Configuration.getConfig()?.chargingStationsPerWorker
: WorkerConstants.DEFAULT_ELEMENTS_PER_WORKER,
? Configuration.getConfig()?.chargingStationsPerWorker
: WorkerConstants.DEFAULT_ELEMENTS_PER_WORKER,
- elementStartDelay: Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'elementStartDelay')
+ elementStartDelay: Utils.
hasOwnProp
(Configuration.getConfig(), 'elementStartDelay')
? Configuration.getConfig()?.elementStartDelay
: WorkerConstants.DEFAULT_ELEMENT_START_DELAY,
? Configuration.getConfig()?.elementStartDelay
: WorkerConstants.DEFAULT_ELEMENT_START_DELAY,
- poolMinSize: Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'workerPoolMinSize')
+ poolMinSize: Utils.
hasOwnProp
(Configuration.getConfig(), 'workerPoolMinSize')
? Configuration.getConfig()?.workerPoolMinSize
: WorkerConstants.DEFAULT_POOL_MIN_SIZE,
? Configuration.getConfig()?.workerPoolMinSize
: WorkerConstants.DEFAULT_POOL_MIN_SIZE,
- poolMaxSize: Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'workerPoolMaxSize')
+ poolMaxSize: Utils.
hasOwnProp
(Configuration.getConfig(), 'workerPoolMaxSize')
? Configuration.getConfig()?.workerPoolMaxSize
: WorkerConstants.DEFAULT_POOL_MAX_SIZE,
poolStrategy:
Configuration.getConfig()?.workerPoolStrategy ?? WorkerChoiceStrategies.ROUND_ROBIN,
};
? Configuration.getConfig()?.workerPoolMaxSize
: WorkerConstants.DEFAULT_POOL_MAX_SIZE,
poolStrategy:
Configuration.getConfig()?.workerPoolStrategy ?? WorkerChoiceStrategies.ROUND_ROBIN,
};
- if (Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'worker')) {
+ if (Utils.
hasOwnProp
(Configuration.getConfig(), 'worker')) {
workerConfiguration = { ...workerConfiguration, ...Configuration.getConfig()?.worker };
}
return workerConfiguration;
workerConfiguration = { ...workerConfiguration, ...Configuration.getConfig()?.worker };
}
return workerConfiguration;
@@
-222,45
+222,45
@@
export class Configuration {
undefined,
"Use 'logConsole' instead"
);
undefined,
"Use 'logConsole' instead"
);
- return Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'logConsole')
+ return Utils.
hasOwnProp
(Configuration.getConfig(), 'logConsole')
? Configuration.getConfig()?.logConsole
: false;
}
static getLogFormat(): string | undefined {
? Configuration.getConfig()?.logConsole
: false;
}
static getLogFormat(): string | undefined {
- return Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'logFormat')
+ return Utils.
hasOwnProp
(Configuration.getConfig(), 'logFormat')
? Configuration.getConfig()?.logFormat
: 'simple';
}
static getLogRotate(): boolean | undefined {
? Configuration.getConfig()?.logFormat
: 'simple';
}
static getLogRotate(): boolean | undefined {
- return Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'logRotate')
+ return Utils.
hasOwnProp
(Configuration.getConfig(), 'logRotate')
? Configuration.getConfig()?.logRotate
: true;
}
static getLogMaxFiles(): number | string | false | undefined {
return (
? Configuration.getConfig()?.logRotate
: true;
}
static getLogMaxFiles(): number | string | false | undefined {
return (
- Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'logMaxFiles') &&
+ Utils.
hasOwnProp
(Configuration.getConfig(), 'logMaxFiles') &&
Configuration.getConfig()?.logMaxFiles
);
}
static getLogMaxSize(): number | string | false | undefined {
return (
Configuration.getConfig()?.logMaxFiles
);
}
static getLogMaxSize(): number | string | false | undefined {
return (
- Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'logMaxFiles') &&
+ Utils.
hasOwnProp
(Configuration.getConfig(), 'logMaxFiles') &&
Configuration.getConfig()?.logMaxSize
);
}
static getLogLevel(): string | undefined {
Configuration.getConfig()?.logMaxSize
);
}
static getLogLevel(): string | undefined {
- return Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'logLevel')
+ return Utils.
hasOwnProp
(Configuration.getConfig(), 'logLevel')
? Configuration.getConfig()?.logLevel?.toLowerCase()
: 'info';
}
static getLogFile(): string | undefined {
? Configuration.getConfig()?.logLevel?.toLowerCase()
: 'info';
}
static getLogFile(): string | undefined {
- return Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'logFile')
+ return Utils.
hasOwnProp
(Configuration.getConfig(), 'logFile')
? Configuration.getConfig()?.logFile
: 'combined.log';
}
? Configuration.getConfig()?.logFile
: 'combined.log';
}
@@
-271,7
+271,7
@@
export class Configuration {
undefined,
"Use 'logErrorFile' instead"
);
undefined,
"Use 'logErrorFile' instead"
);
- return Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'logErrorFile')
+ return Utils.
hasOwnProp
(Configuration.getConfig(), 'logErrorFile')
? Configuration.getConfig()?.logErrorFile
: 'error.log';
}
? Configuration.getConfig()?.logErrorFile
: 'error.log';
}
@@
-301,7
+301,7
@@
export class Configuration {
undefined,
"Use 'supervisionUrlDistribution' instead"
);
undefined,
"Use 'supervisionUrlDistribution' instead"
);
- return Utils.
objectHasOwnProperty
(Configuration.getConfig(), 'supervisionUrlDistribution')
+ return Utils.
hasOwnProp
(Configuration.getConfig(), 'supervisionUrlDistribution')
? Configuration.getConfig()?.supervisionUrlDistribution
: SupervisionUrlDistribution.ROUND_ROBIN;
}
? Configuration.getConfig()?.supervisionUrlDistribution
: SupervisionUrlDistribution.ROUND_ROBIN;
}
@@
-322,13
+322,13
@@
export class Configuration {
) {
console.error(
chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key '${key}' usage in section '${sectionName}'${
) {
console.error(
chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key '${key}' usage in section '${sectionName}'${
- logMsgToAppend.trim().length > 0
&& `. ${logMsgToAppend}`
+ logMsgToAppend.trim().length > 0
? `. ${logMsgToAppend}` : ''
}}`
);
} else if (!Utils.isUndefined(Configuration.getConfig()[key])) {
console.error(
chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key '${key}' usage${
}}`
);
} else if (!Utils.isUndefined(Configuration.getConfig()[key])) {
console.error(
chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key '${key}' usage${
- logMsgToAppend.trim().length > 0
&& `. ${logMsgToAppend}`
+ logMsgToAppend.trim().length > 0
? `. ${logMsgToAppend}` : ''
}}`
);
}
}}`
);
}