Rename StationWorker.ts to ChargingStationWorker.ts
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Aug 2021 06:32:00 +0000 (08:32 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Aug 2021 06:32:00 +0000 (08:32 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
rollup.config.js
src/charging-station/Bootstrap.ts
src/charging-station/ChargingStationWorker.ts [moved from src/charging-station/StationWorker.ts with 77% similarity]
src/types/Worker.ts

index 58de2f5dfc301c0417fc7feb8c7497737ba5d383..e6b710e8d9a028460adea339091f41add0056993 100644 (file)
@@ -9,7 +9,7 @@ import typescript from 'rollup-plugin-typescript2';
 const isDevelopmentBuild = process.env.BUILD === 'development';
 
 export default {
-  input: ['src/start.ts', 'src/charging-station/StationWorker.ts'],
+  input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'],
   output:
   {
     dir: 'dist',
index e97c1c6c15b4ebc81bb17d6ad65007d261b1e5af..b018df60949332198edd94128c10c53505f98cd9 100644 (file)
@@ -1,4 +1,4 @@
-import { StationWorkerData, WorkerEvents, WorkerMessage } from '../types/Worker';
+import { ChargingStationWorkerData, WorkerEvents, WorkerMessage } from '../types/Worker';
 
 import Configuration from '../utils/Configuration';
 import { Storage } from '../utils/performance-storage/Storage';
@@ -21,7 +21,7 @@ export default class Bootstrap {
 
   private constructor() {
     this.started = false;
-    this.workerScript = path.join(path.resolve(__dirname, '../'), 'charging-station', 'StationWorker.js');
+    this.workerScript = path.join(path.resolve(__dirname, '../'), 'charging-station', 'ChargingStationWorker.js');
     this.initWorkerImplementation();
     Bootstrap.storage = StorageFactory.getStorage(Configuration.getPerformanceStorage().type, Configuration.getPerformanceStorage().URI, this.logPrefix());
     Configuration.setConfigurationChangeCallback(async () => Bootstrap.getInstance().restart());
@@ -45,7 +45,7 @@ export default class Bootstrap {
             try {
               const nbStations = stationURL.numberOfStations ? stationURL.numberOfStations : 0;
               for (let index = 1; index <= nbStations; index++) {
-                const workerData: StationWorkerData = {
+                const workerData: ChargingStationWorkerData = {
                   index,
                   templateFile: path.join(path.resolve(__dirname, '../'), 'assets', 'station-templates', path.basename(stationURL.file))
                 };
@@ -85,7 +85,7 @@ export default class Bootstrap {
   }
 
   private initWorkerImplementation() {
-    Bootstrap.workerImplementation = WorkerFactory.getWorkerImplementation<StationWorkerData>(this.workerScript, Configuration.getWorkerProcess(),
+    Bootstrap.workerImplementation = WorkerFactory.getWorkerImplementation<ChargingStationWorkerData>(this.workerScript, Configuration.getWorkerProcess(),
       {
         startDelay: Configuration.getWorkerStartDelay(),
         poolMaxSize: Configuration.getWorkerPoolMaxSize(),
similarity index 77%
rename from src/charging-station/StationWorker.ts
rename to src/charging-station/ChargingStationWorker.ts
index dd0f377ceff295c7df8980ece4931d5545dfa9da..20a812e496a78f1f128b88a2f33df652ab04ee74 100644 (file)
@@ -1,6 +1,6 @@
 // Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
 
-import { StationWorkerData, WorkerEvents, WorkerMessage } from '../types/Worker';
+import { ChargingStationWorkerData, WorkerEvents, WorkerMessage } from '../types/Worker';
 import { parentPort, workerData } from 'worker_threads';
 
 import ChargingStation from './ChargingStation';
@@ -11,7 +11,7 @@ import Utils from '../utils/Utils';
 // Conditionally export ThreadWorker instance for pool usage
 export let threadWorker: ThreadWorker;
 if (Utils.workerPoolInUse()) {
-  threadWorker = new ThreadWorker<StationWorkerData>(startChargingStation, { maxInactiveTime: Constants.WORKER_POOL_MAX_INACTIVE_TIME, async: false });
+  threadWorker = new ThreadWorker<ChargingStationWorkerData>(startChargingStation, { maxInactiveTime: Constants.WORKER_POOL_MAX_INACTIVE_TIME, async: false });
 } else {
   // Add message listener to start charging station from main thread
   addMessageListener();
@@ -36,7 +36,7 @@ function addMessageListener(): void {
  *
  * @param data workerData
  */
-function startChargingStation(data: StationWorkerData): void {
+function startChargingStation(data: ChargingStationWorkerData): void {
   const station = new ChargingStation(data.index, data.templateFile);
   station.start();
 }
index eedf5611b773a6f723ce662b189e1572c99432b3..b0fe6e76fecbff82ec27eb5a30eff5a9f078cb05 100644 (file)
@@ -18,7 +18,7 @@ export interface WorkerOptions {
 // eslint-disable-next-line @typescript-eslint/no-empty-interface
 export interface WorkerData {}
 
-export interface StationWorkerData extends WorkerData {
+export interface ChargingStationWorkerData extends WorkerData {
   index: number;
   templateFile: string;
 }