X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fperformance%2Fstorage%2FStorage.ts;h=ccdbb3f835411c27521e1c17df33002d7cfd259a;hb=6c0215d2bf5a098aceed9e9d94d75d50ff2630db;hp=d9539190cced18006c52d8845dd62ac5ec6b0b37;hpb=4ccf551d961ef001acef6fafe1165ad9b6dac4e3;p=e-mobility-charging-stations-simulator.git diff --git a/src/performance/storage/Storage.ts b/src/performance/storage/Storage.ts index d9539190..ccdbb3f8 100644 --- a/src/performance/storage/Storage.ts +++ b/src/performance/storage/Storage.ts @@ -15,19 +15,23 @@ export abstract class Storage { protected readonly storageUri: URL protected readonly logPrefix: string protected dbName!: string + private static readonly performanceStatistics = new Map() constructor (storageUri: string, logPrefix: string) { this.storageUri = new URL(storageUri) this.logPrefix = logPrefix } - protected handleDBError ( + protected handleDBStorageError ( type: StorageType, error: Error, table?: string, - params: HandleErrorParams = { throwError: false, consoleOut: false } + params: HandleErrorParams = { + throwError: false, + consoleOut: false + } ): void { - setDefaultErrorParams(params, { throwError: false, consoleOut: false }) + params = setDefaultErrorParams(params, { throwError: false, consoleOut: false }) const inTableOrCollectionStr = table != null && ` in table or collection '${table}'` logger.error( `${this.logPrefix} ${this.getDBNameFromStorageType(type)} error '${ @@ -53,6 +57,18 @@ export abstract class Storage { } } + public getPerformanceStatistics (): IterableIterator { + return Storage.performanceStatistics.values() + } + + protected setPerformanceStatistics (performanceStatistics: Statistics): void { + Storage.performanceStatistics.set(performanceStatistics.id, performanceStatistics) + } + + protected clearPerformanceStatistics (): void { + Storage.performanceStatistics.clear() + } + public abstract open (): void | Promise public abstract close (): void | Promise public abstract storePerformanceStatistics (