Type properly station worker data.
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 25 Jan 2021 20:49:39 +0000 (21:49 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 25 Jan 2021 20:49:39 +0000 (21:49 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/StationWorker.ts
src/start.ts
src/types/Worker.ts

index 8ddffc4e0b9abbe709d9eb2c560c719c4a8054a5..1b529190cb10c99f98c0b2ce5b9b17a48fc29a1c 100644 (file)
@@ -1,4 +1,4 @@
-import { WorkerData, WorkerEvents } from '../types/Worker';
+import { StationWorkerData, WorkerEvents } from '../types/Worker';
 import { isMainThread, parentPort, workerData } from 'worker_threads';
 
 import ChargingStation from './ChargingStation';
@@ -22,7 +22,7 @@ function addListener() {
   });
 }
 
-function startChargingStation(data: WorkerData) {
+function startChargingStation(data: StationWorkerData) {
   const station = new ChargingStation(data.index , data.templateFile);
   station.start();
 }
index c0eab94135e65270a9c193fa1393d116faf559a9..5aaeea9f940235ba0641122e8da86e91ae7f4529 100644 (file)
@@ -1,6 +1,6 @@
 import Configuration from './utils/Configuration';
+import { StationWorkerData } from './types/Worker';
 import Utils from './utils/Utils';
-import { WorkerData } from './types/Worker';
 import WorkerFactory from './worker/WorkerFactory';
 import Wrk from './worker/Wrk';
 
@@ -16,7 +16,7 @@ class Bootstrap {
           try {
             const nbStations = stationURL.numberOfStations ? stationURL.numberOfStations : 0;
             for (let index = 1; index <= nbStations; index++) {
-              const workerData: WorkerData = {
+              const workerData: StationWorkerData = {
                 index,
                 templateFile: stationURL.file
               };
index 20c4488224f620f68e415426384446fb1239a7ed..6ec9e9997ca1a17f33daa435eb0b34e43fd8bb02 100644 (file)
@@ -6,8 +6,9 @@ export enum WorkerProcessType {
   STATIC_POOL = 'staticPool'
 }
 
-// FIXME: make it more generic
-export interface WorkerData {
+export interface WorkerData { }
+
+export interface StationWorkerData extends WorkerData {
   index: number;
   templateFile: string;
 }