From: Jérôme Benoit Date: Fri, 14 Jul 2023 18:49:33 +0000 (+0200) Subject: refactor: remove pool strategy from worker configuration section X-Git-Tag: v1.2.18~33 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=eda9c4514246fca7fb42572936dfe2b018abb8e5;p=e-mobility-charging-stations-simulator.git refactor: remove pool strategy from worker configuration section Signed-off-by: Jérôme Benoit --- diff --git a/README.md b/README.md index 49fbeb02..c5f9409f 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ But the modifications to test have to be done to the files in the build target d | supervisionUrls | | [] | string \| string[] | string or strings array containing global connection URIs to OCPP-J servers | | supervisionUrlDistribution | round-robin/random/charging-station-affinity | charging-station-affinity | string | supervision urls distribution policy to simulated charging stations | | log | | {
"enabled": true,
"file": "logs/combined.log",
"errorFile": "logs/error.log",
"statisticsInterval": 60,
"level": "info",
"console": false,
"format": "simple",
"rotate": true
} | {
enabled: boolean;
file: string;
errorFile: string;
statisticsInterval: number;
level: string;
console: boolean;
format: string;
rotate: boolean;
maxFiles: string \| number;
maxSize: string \| number;
} | Log configuration section:
- _enabled_: enable logging
- _file_: log file relative path
- _errorFile_: error log file relative path
- _statisticsInterval_: seconds between charging stations statistics output in the logs
- _level_: emerg/alert/crit/error/warning/notice/info/debug [winston](https://github.com/winstonjs/winston) logging level
- _console_: output logs on the console
- _format_: [winston](https://github.com/winstonjs/winston) log format
- _rotate_: enable daily log files rotation
- _maxFiles_: maximum number of log files: https://github.com/winstonjs/winston-daily-rotate-file#options
- _maxSize_: maximum size of log files in bytes, or units of kb, mb, and gb: https://github.com/winstonjs/winston-daily-rotate-file#options | -| worker | | {
"processType": "workerSet",
"startDelay": 500,
"elementStartDelay": 0,
"elementsPerWorker": 'auto',
"poolMinSize": 4,
"poolMaxSize": 16,
"poolStrategy": "ROUND_ROBIN"
} | {
processType: WorkerProcessType;
startDelay: number;
elementStartDelay: number;
elementsPerWorker: number \| 'auto';
poolMinSize: number;
poolMaxSize: number;
poolStrategy: WorkerChoiceStrategy;
} | Worker configuration section:
- _processType_: worker threads process type (`workerSet`/`staticPool`/`dynamicPool`)
- _startDelay_: milliseconds to wait at worker threads startup (only for `workerSet` worker threads process type)
- _elementStartDelay_: milliseconds to wait at charging station startup
- _elementsPerWorker_: number of charging stations per worker threads for the `workerSet` process type (`auto` means (number of stations) / (number of CPUs) if (number of stations) > (number of CPUs), otherwise 1)
- _poolMinSize_: worker threads pool minimum number of threads
- _poolMaxSize_: worker threads pool maximum number of threads
- _poolStrategy_: worker threads pool [poolifier](https://github.com/poolifier/poolifier) worker choice strategy | +| worker | | {
"processType": "workerSet",
"startDelay": 500,
"elementStartDelay": 0,
"elementsPerWorker": 'auto',
"poolMinSize": 4,
"poolMaxSize": 16} | {
processType: WorkerProcessType;
startDelay: number;
elementStartDelay: number;
elementsPerWorker: number \| 'auto';
poolMinSize: number;
poolMaxSize: number;
} | Worker configuration section:
- _processType_: worker threads process type (`workerSet`/`staticPool`/`dynamicPool`)
- _startDelay_: milliseconds to wait at worker threads startup (only for `workerSet` worker threads process type)
- _elementStartDelay_: milliseconds to wait at charging station startup
- _elementsPerWorker_: number of charging stations per worker threads for the `workerSet` process type (`auto` means (number of stations) / (number of CPUs) if (number of stations) > (number of CPUs), otherwise 1)
- _poolMinSize_: worker threads pool minimum number of threads
- _poolMaxSize_: worker threads pool maximum number of threads | | uiServer | | {
"enabled": false,
"type": "ws",
"options": {
"host": "localhost",
"port": 8080
}
} | {
enabled: boolean;
type: ApplicationProtocol;
options: ServerOptions;
authentication: {
enabled: boolean;
type: AuthenticationType;
username: string;
password: string;
}
} | UI server configuration section | | performanceStorage | | {
"enabled": false,
"type": "jsonfile",
"file:///performanceRecords.json"
} | {
enabled: boolean;
type: string;
URI: string;
}
where type can be 'jsonfile' or 'mongodb' | performance storage configuration section | | stationTemplateUrls | | {}[] | {
file: string;
numberOfStations: number;
}[] | array of charging station configuration templates URIs configuration section (charging station configuration template file name and number of stations) | diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 1550f6a7..13774cc6 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -36,7 +36,7 @@ import { logPrefix, logger, } from '../utils'; -import { type WorkerAbstract, WorkerConstants, WorkerFactory } from '../worker'; +import { type WorkerAbstract, WorkerFactory } from '../worker'; const moduleName = 'Bootstrap'; @@ -231,7 +231,6 @@ export class Bootstrap extends EventEmitter { elementsPerWorker: elementsPerWorker ?? (Configuration.getWorker().elementsPerWorker as number), poolOptions: { - workerChoiceStrategy: Configuration.getWorker().poolStrategy, messageHandler: this.messageHandler.bind(this) as (message: unknown) => void, }, }, diff --git a/src/types/ConfigurationData.ts b/src/types/ConfigurationData.ts index 94ac3b34..accdcc21 100644 --- a/src/types/ConfigurationData.ts +++ b/src/types/ConfigurationData.ts @@ -57,6 +57,7 @@ export type WorkerConfiguration = { elementStartDelay?: number; poolMinSize?: number; poolMaxSize?: number; + /** @deprecated Not publicly exposed to end users. */ poolStrategy?: WorkerChoiceStrategy; }; diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 92ce46e3..691721e9 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -4,7 +4,6 @@ import { fileURLToPath } from 'node:url'; import chalk from 'chalk'; import merge from 'just-merge'; -import { WorkerChoiceStrategies } from 'poolifier'; import { Constants } from './Constants'; import { hasOwnProp, isCFEnvironment, isNotEmptyString, isUndefined } from './Utils'; @@ -292,8 +291,9 @@ export class Configuration { elementStartDelay: WorkerConstants.DEFAULT_ELEMENT_START_DELAY, poolMinSize: WorkerConstants.DEFAULT_POOL_MIN_SIZE, poolMaxSize: WorkerConstants.DEFAULT_POOL_MAX_SIZE, - poolStrategy: WorkerChoiceStrategies.ROUND_ROBIN, }; + hasOwnProp(Configuration.getConfig(), 'workerPoolStrategy') && + delete Configuration.getConfig()?.workerPoolStrategy; const deprecatedWorkerConfiguration: WorkerConfiguration = { ...(hasOwnProp(Configuration.getConfig(), 'workerProcess') && { processType: Configuration.getConfig()?.workerProcess, @@ -313,11 +313,12 @@ export class Configuration { ...(hasOwnProp(Configuration.getConfig(), 'workerPoolMaxSize') && { poolMaxSize: Configuration.getConfig()?.workerPoolMaxSize, }), - ...(hasOwnProp(Configuration.getConfig(), 'workerPoolStrategy') && { - poolStrategy: - Configuration.getConfig()?.workerPoolStrategy ?? WorkerChoiceStrategies.ROUND_ROBIN, - }), }; + Configuration.warnDeprecatedConfigurationKey( + 'poolStrategy', + 'worker', + 'Not publicly exposed to end users', + ); const workerConfiguration: WorkerConfiguration = { ...defaultWorkerConfiguration, ...deprecatedWorkerConfiguration,