b8922375c39f3e983406aac5e0413968d31a3ec9
1 import { DBType
} from
'../../types/Storage';
2 import Statistics from
'../../types/Statistics';
3 import { URL
} from
'url';
4 import logger from
'../Logger';
6 export abstract class Storage
{
7 protected readonly storageURI
: URL
;
8 protected readonly logPrefix
: string;
9 protected dbName
: string;
11 constructor(storageURI
: string, logPrefix
: string) {
12 this.storageURI
= new URL(storageURI
);
13 this.logPrefix
= logPrefix
;
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);
20 public abstract open(): void | Promise<void>;
21 public abstract close(): void | Promise<void>;
22 public abstract storePerformanceStatistics(performanceStatistics: Statistics): void | Promise<void>;