From 07f350040f34e6727c548bc645e9982c189cd4ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 27 Aug 2021 08:32:00 +0200 Subject: [PATCH] Rename StationWorker.ts to ChargingStationWorker.ts MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- rollup.config.js | 2 +- src/charging-station/Bootstrap.ts | 8 ++++---- .../{StationWorker.ts => ChargingStationWorker.ts} | 6 +++--- src/types/Worker.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename src/charging-station/{StationWorker.ts => ChargingStationWorker.ts} (77%) diff --git a/rollup.config.js b/rollup.config.js index 58de2f5d..e6b710e8 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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', diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index e97c1c6c..b018df60 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -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(this.workerScript, Configuration.getWorkerProcess(), + Bootstrap.workerImplementation = WorkerFactory.getWorkerImplementation(this.workerScript, Configuration.getWorkerProcess(), { startDelay: Configuration.getWorkerStartDelay(), poolMaxSize: Configuration.getWorkerPoolMaxSize(), diff --git a/src/charging-station/StationWorker.ts b/src/charging-station/ChargingStationWorker.ts similarity index 77% rename from src/charging-station/StationWorker.ts rename to src/charging-station/ChargingStationWorker.ts index dd0f377c..20a812e4 100644 --- a/src/charging-station/StationWorker.ts +++ b/src/charging-station/ChargingStationWorker.ts @@ -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(startChargingStation, { maxInactiveTime: Constants.WORKER_POOL_MAX_INACTIVE_TIME, async: false }); + threadWorker = new ThreadWorker(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(); } diff --git a/src/types/Worker.ts b/src/types/Worker.ts index eedf5611..b0fe6e76 100644 --- a/src/types/Worker.ts +++ b/src/types/Worker.ts @@ -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; } -- 2.34.1