refactor: cleanup charging station worker namespace
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 4 Feb 2024 19:12:30 +0000 (20:12 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 4 Feb 2024 19:12:30 +0000 (20:12 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStationWorker.ts

index 21050d206d60ec2fb1f5623696a2e633c6e50a8f..5bbfa6dd092ec485d670b02c1b639a1539d2542b 100644 (file)
@@ -11,11 +11,11 @@ import { Configuration } from '../utils/index.js'
 import { type WorkerMessage, WorkerMessageEvents } from '../worker/index.js'
 
 /**
- * Creates and starts a charging station instance
+ * Adds and starts a charging station instance
  *
  * @param data - data sent to worker
  */
-const startChargingStation = (data?: ChargingStationWorkerData): void => {
+const addChargingStation = (data?: ChargingStationWorkerData): void => {
   // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
   new ChargingStation(data!.index, data!.templateFile).start()
 }
@@ -28,7 +28,7 @@ class ChargingStationWorker<Data extends ChargingStationWorkerData> {
       switch (message.event) {
         case WorkerMessageEvents.startWorkerElement:
           try {
-            startChargingStation(message.data)
+            addChargingStation(message.data)
             parentPort?.postMessage({
               event: WorkerMessageEvents.startedWorkerElement
             })
@@ -60,7 +60,7 @@ export let chargingStationWorker:
 | ChargingStationWorker<ChargingStationWorkerData>
 | ThreadWorker<ChargingStationWorkerData>
 if (Configuration.workerPoolInUse()) {
-  chargingStationWorker = new ThreadWorker<ChargingStationWorkerData>(startChargingStation)
+  chargingStationWorker = new ThreadWorker<ChargingStationWorkerData>(addChargingStation)
 } else {
   chargingStationWorker = new ChargingStationWorker<ChargingStationWorkerData>()
 }