- static getWorkerPoolMinSize(): number {
- return Configuration.objectHasOwnProperty(Configuration.getConfig(), 'workerPoolMinSize') ? Configuration.getConfig().workerPoolMinSize : Constants.DEFAULT_WORKER_POOL_MIN_SIZE;
- }
-
- static getWorkerPoolMaxSize(): number {
- Configuration.warnDeprecatedConfigurationKey('workerPoolSize;', null, 'Use \'workerPoolMaxSize\' instead');
- return Configuration.objectHasOwnProperty(Configuration.getConfig(), 'workerPoolMaxSize') ? Configuration.getConfig().workerPoolMaxSize : Constants.DEFAULT_WORKER_POOL_MAX_SIZE;
- }
-
- static getWorkerPoolStrategy(): WorkerChoiceStrategy {
- return Configuration.getConfig().workerPoolStrategy;
+ static getWorker(): WorkerConfiguration {
+ Configuration.warnDeprecatedConfigurationKey(
+ 'useWorkerPool',
+ undefined,
+ "Use 'worker' section to define the type of worker process model instead"
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerProcess',
+ undefined,
+ "Use 'worker' section to define the type of worker process model instead"
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerStartDelay',
+ undefined,
+ "Use 'worker' section to define the worker start delay instead"
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'chargingStationsPerWorker',
+ undefined,
+ "Use 'worker' section to define the number of element(s) per worker instead"
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'elementStartDelay',
+ undefined,
+ "Use 'worker' section to define the worker's element start delay instead"
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerPoolMinSize',
+ undefined,
+ "Use 'worker' section to define the worker pool minimum size instead"
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerPoolSize;',
+ undefined,
+ "Use 'worker' section to define the worker pool maximum size instead"
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerPoolMaxSize;',
+ undefined,
+ "Use 'worker' section to define the worker pool maximum size instead"
+ );
+ Configuration.warnDeprecatedConfigurationKey(
+ 'workerPoolStrategy;',
+ undefined,
+ "Use 'worker' section to define the worker pool strategy instead"
+ );
+ let workerConfiguration: WorkerConfiguration = {
+ processType: Utils.hasOwnProp(Configuration.getConfig(), 'workerProcess')
+ ? Configuration.getConfig()?.workerProcess
+ : WorkerProcessType.workerSet,
+ startDelay: Utils.hasOwnProp(Configuration.getConfig(), 'workerStartDelay')
+ ? Configuration.getConfig()?.workerStartDelay
+ : WorkerConstants.DEFAULT_WORKER_START_DELAY,
+ elementsPerWorker: Utils.hasOwnProp(Configuration.getConfig(), 'chargingStationsPerWorker')
+ ? Configuration.getConfig()?.chargingStationsPerWorker
+ : WorkerConstants.DEFAULT_ELEMENTS_PER_WORKER,
+ elementStartDelay: Utils.hasOwnProp(Configuration.getConfig(), 'elementStartDelay')
+ ? Configuration.getConfig()?.elementStartDelay
+ : WorkerConstants.DEFAULT_ELEMENT_START_DELAY,
+ poolMinSize: Utils.hasOwnProp(Configuration.getConfig(), 'workerPoolMinSize')
+ ? Configuration.getConfig()?.workerPoolMinSize
+ : WorkerConstants.DEFAULT_POOL_MIN_SIZE,
+ poolMaxSize: Utils.hasOwnProp(Configuration.getConfig(), 'workerPoolMaxSize')
+ ? Configuration.getConfig()?.workerPoolMaxSize
+ : WorkerConstants.DEFAULT_POOL_MAX_SIZE,
+ poolStrategy:
+ Configuration.getConfig()?.workerPoolStrategy ?? WorkerChoiceStrategies.ROUND_ROBIN,
+ };
+ if (Utils.hasOwnProp(Configuration.getConfig(), 'worker')) {
+ workerConfiguration = { ...workerConfiguration, ...Configuration.getConfig()?.worker };
+ }
+ return workerConfiguration;