X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2Fperformance-storage%2FStorage.ts;fp=src%2Futils%2Fperformance-storage%2FStorage.ts;h=0000000000000000000000000000000000000000;hb=a6b3c6c313f1c0314a1445ed630cac85edf55b2c;hp=160e01d8bdc435adf68dbb782e22169a1f3676cc;hpb=de96acad9df699ff34f25e32ba616ef5c09ff124;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/performance-storage/Storage.ts b/src/utils/performance-storage/Storage.ts deleted file mode 100644 index 160e01d8..00000000 --- a/src/utils/performance-storage/Storage.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright Jerome Benoit. 2021. All Rights Reserved. - -import { DBType, StorageType } from '../../types/Storage'; - -import Statistics from '../../types/Statistics'; -import { URL } from 'url'; -import Utils from '../Utils'; -import logger from '../Logger'; - -export abstract class Storage { - protected readonly storageURI: URL; - protected readonly logPrefix: string; - protected dbName: string; - - constructor(storageURI: string, logPrefix: string) { - this.storageURI = new URL(storageURI); - this.logPrefix = logPrefix; - } - - protected handleDBError(type: StorageType, error: Error, table?: string): void { - logger.error(`${this.logPrefix} ${this.getDBTypeFromStorageType(type)} error${(!Utils.isNullOrUndefined(table) || !table) && ` in table or collection '${table}'`} %j`, error); - } - - protected getDBTypeFromStorageType(type: StorageType): DBType { - switch (type) { - case StorageType.MARIA_DB: - return DBType.MARIA_DB; - case StorageType.MONGO_DB: - return DBType.MONGO_DB; - case StorageType.MYSQL: - return DBType.MYSQL; - case StorageType.SQLITE: - return DBType.SQLITE; - } - } - - public abstract open(): void | Promise; - public abstract close(): void | Promise; - public abstract storePerformanceStatistics(performanceStatistics: Statistics): void | Promise; -}