Improve OCPP error handling, fix performance storage default file path
[e-mobility-charging-stations-simulator.git] / src / performance / storage / StorageFactory.ts
CommitLineData
c27c3eee
JB
1// Copyright Jerome Benoit. 2021. All Rights Reserved.
2
72f041bd 3import { JSONFileStorage } from './JSONFileStorage';
a6b3c6c3 4import { MikroORMStorage } from './MikroORMStorage';
72f041bd
JB
5import { MongoDBStorage } from './MongoDBStorage';
6import { Storage } from './Storage';
7import { StorageType } from '../../types/Storage';
72f041bd
JB
8
9export class StorageFactory {
10 // eslint-disable-next-line @typescript-eslint/no-empty-function
6c3cfef8
JB
11 private constructor() {
12 // This is intentional
13 }
72f041bd
JB
14
15 public static getStorage(type: StorageType, connectionURI: string, logPrefix: string): Storage {
16 let storageInstance: Storage = null;
17 switch (type) {
18 case StorageType.JSON_FILE:
19 storageInstance = new JSONFileStorage(connectionURI, logPrefix);
20 break;
21 case StorageType.MONGO_DB:
22 storageInstance = new MongoDBStorage(connectionURI, logPrefix);
23 break;
a6b3c6c3
JB
24 // case StorageType.MYSQL:
25 // case StorageType.MARIA_DB:
26 // case StorageType.SQLITE:
27 // storageInstance = new MikroORMStorage(connectionURI, logPrefix, type);
28 // break;
72f041bd 29 default:
fb226c9b 30 throw new Error(`${logPrefix} Unknown storage type: ${type}`);
72f041bd
JB
31 }
32 return storageInstance;
33 }
34}