From 46eb543c2eb31661c078b7e9697dacc593d83e5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 25 Jan 2021 21:49:39 +0100 Subject: [PATCH] Type properly station worker data. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/StationWorker.ts | 4 ++-- src/start.ts | 4 ++-- src/types/Worker.ts | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/charging-station/StationWorker.ts b/src/charging-station/StationWorker.ts index 8ddffc4e..1b529190 100644 --- a/src/charging-station/StationWorker.ts +++ b/src/charging-station/StationWorker.ts @@ -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(); } diff --git a/src/start.ts b/src/start.ts index c0eab941..5aaeea9f 100644 --- a/src/start.ts +++ b/src/start.ts @@ -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 }; diff --git a/src/types/Worker.ts b/src/types/Worker.ts index 20c44882..6ec9e999 100644 --- a/src/types/Worker.ts +++ b/src/types/Worker.ts @@ -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; } -- 2.34.1