X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStationWorker.ts;h=6201bf07e2b52fe7e6d1931412da74e89043717c;hb=248f70eff6b955b177f0bbd9ca84356c3b99d72e;hp=db7ae2cb4462ff79f50359dc989b50536a73edd6;hpb=f93dda6ae88071623a20bd4171026222cf66c631;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStationWorker.ts b/src/charging-station/ChargingStationWorker.ts index db7ae2cb..6201bf07 100644 --- a/src/charging-station/ChargingStationWorker.ts +++ b/src/charging-station/ChargingStationWorker.ts @@ -6,9 +6,10 @@ import { parentPort } from 'node:worker_threads'; import { ThreadWorker } from 'poolifier'; import { ChargingStation } from './ChargingStation'; +import { BaseError } from '../exception'; import type { ChargingStationWorkerData } from '../types'; import { Configuration } from '../utils'; -import { WorkerConstants, type WorkerMessage, WorkerMessageEvents } from '../worker'; +import { type WorkerMessage, WorkerMessageEvents } from '../worker'; const moduleName = 'ChargingStationWorker'; @@ -48,10 +49,10 @@ class ChargingStationWorker extends AsyncResource { } break; default: - throw new Error( + throw new BaseError( `Unknown worker event: '${message.event}' received with data: '${JSON.stringify( message.data, - null, + undefined, 2, )}'`, ); @@ -62,9 +63,7 @@ class ChargingStationWorker extends AsyncResource { export let chargingStationWorker: ChargingStationWorker | ThreadWorker; if (Configuration.workerPoolInUse()) { - chargingStationWorker = new ThreadWorker(startChargingStation, { - maxInactiveTime: WorkerConstants.POOL_MAX_INACTIVE_TIME, - }); + chargingStationWorker = new ThreadWorker(startChargingStation); } else { chargingStationWorker = new ChargingStationWorker(); }