From: Jérôme Benoit Date: Wed, 29 Nov 2023 19:11:39 +0000 (+0100) Subject: refactor: add type for worker configuration attribute X-Git-Tag: v1.2.28~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=47fb5f8f8370c85553eb65f8e4bfbbc233967682;p=e-mobility-charging-stations-simulator.git refactor: add type for worker configuration attribute Signed-off-by: Jérôme Benoit --- diff --git a/src/types/ConfigurationData.ts b/src/types/ConfigurationData.ts index cac78689..df362b53 100644 --- a/src/types/ConfigurationData.ts +++ b/src/types/ConfigurationData.ts @@ -64,10 +64,12 @@ export interface StorageConfiguration { uri?: string; } +export type elementsPerWorkerType = number | 'auto' | 'all'; + export interface WorkerConfiguration { processType?: WorkerProcessType; startDelay?: number; - elementsPerWorker?: number | 'auto' | 'all'; + elementsPerWorker?: elementsPerWorkerType; elementStartDelay?: number; poolMinSize?: number; poolMaxSize?: number; diff --git a/src/utils/ConfigurationUtils.ts b/src/utils/ConfigurationUtils.ts index 50bad0fa..660bc764 100644 --- a/src/utils/ConfigurationUtils.ts +++ b/src/utils/ConfigurationUtils.ts @@ -6,6 +6,7 @@ import chalk from 'chalk'; import { Constants } from './Constants'; import { isNotEmptyString, logPrefix as utilsLogPrefix } from './Utils'; import { FileType, StorageType } from '../types'; +import type { elementsPerWorkerType } from '../types/ConfigurationData'; import { WorkerProcessType } from '../worker'; export const logPrefix = (): string => { @@ -68,7 +69,7 @@ export const checkWorkerProcessType = (workerProcessType: WorkerProcessType): vo }; export const checkWorkerElementsPerWorker = ( - elementsPerWorker: number | 'auto' | 'all' | undefined, + elementsPerWorker: elementsPerWorkerType | undefined, ): void => { if ( elementsPerWorker !== undefined &&