Commit | Line | Data |
---|---|---|
2a370053 | 1 | import { DBType } from '../../types/Storage'; |
72f041bd JB |
2 | import Statistics from '../../types/Statistics'; |
3 | import { URL } from 'url'; | |
2a370053 | 4 | import logger from '../Logger'; |
72f041bd JB |
5 | |
6 | export abstract class Storage { | |
2a370053 JB |
7 | protected readonly storageURI: URL; |
8 | protected readonly logPrefix: string; | |
9 | protected dbName: string; | |
72f041bd JB |
10 | |
11 | constructor(storageURI: string, logPrefix: string) { | |
12 | this.storageURI = new URL(storageURI); | |
13 | this.logPrefix = logPrefix; | |
14 | } | |
15 | ||
2a370053 JB |
16 | protected handleDBError(DBEngine: DBType, error: Error, table?: string): void { |
17 | logger.error(`${this.logPrefix} ${DBEngine} error${table && ` in table or collection ${table}`} %j`, error); | |
18 | } | |
19 | ||
20 | public abstract open(): void | Promise<void>; | |
21 | public abstract close(): void | Promise<void>; | |
22 | public abstract storePerformanceStatistics(performanceStatistics: Statistics): void | Promise<void>; | |
72f041bd | 23 | } |