From: Jérôme Benoit Date: Tue, 19 Mar 2024 17:50:20 +0000 (+0100) Subject: fix: fix worker configuration merge issue X-Git-Tag: v1.3.1~31 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=56f945900ccdbffb165bc42026fa20158c7032fe;p=e-mobility-charging-stations-simulator.git fix: fix worker configuration merge issue Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 6eacfff4..64953a96 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -366,7 +366,9 @@ export class Bootstrap extends EventEmitter { elementsPerWorker, poolOptions: { messageHandler: this.messageHandler.bind(this) as MessageHandler, - workerOptions: { resourceLimits: workerConfiguration.resourceLimits } + ...(workerConfiguration.resourceLimits != null && { + workerOptions: { resourceLimits: workerConfiguration.resourceLimits } + }) } } ) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 29aedcba..92b5fe75 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1244,7 +1244,7 @@ export class ChargingStation extends EventEmitter { stationInfoFromFile.templateHash === stationInfoFromTemplate.templateHash ) { return setChargingStationOptions( - { ...Constants.DEFAULT_STATION_INFO, ...stationInfoFromFile }, + mergeDeepRight(Constants.DEFAULT_STATION_INFO, stationInfoFromFile), options ) } @@ -1255,7 +1255,7 @@ export class ChargingStation extends EventEmitter { stationInfoFromTemplate ) return setChargingStationOptions( - { ...Constants.DEFAULT_STATION_INFO, ...stationInfoFromTemplate }, + mergeDeepRight(Constants.DEFAULT_STATION_INFO, stationInfoFromTemplate), options ) } diff --git a/src/worker/WorkerFactory.ts b/src/worker/WorkerFactory.ts index 833c939f..67da00d8 100644 --- a/src/worker/WorkerFactory.ts +++ b/src/worker/WorkerFactory.ts @@ -1,5 +1,7 @@ import { isMainThread } from 'node:worker_threads' +import { mergeDeepRight } from 'rambda' + import type { WorkerAbstract } from './WorkerAbstract.js' import { DEFAULT_WORKER_OPTIONS } from './WorkerConstants.js' import { WorkerDynamicPool } from './WorkerDynamicPool.js' @@ -21,7 +23,7 @@ export class WorkerFactory { if (!isMainThread) { throw new Error('Cannot get a worker implementation outside the main thread') } - workerOptions = { ...DEFAULT_WORKER_OPTIONS, ...workerOptions } + workerOptions = mergeDeepRight(DEFAULT_WORKER_OPTIONS, workerOptions ?? {}) let workerImplementation: WorkerAbstract switch (workerProcessType) { case WorkerProcessType.workerSet: