MCPcopy Create free account
hub / github.com/Azure/Azurite / LokiTableMetadataStore

Class LokiTableMetadataStore

src/table/persistence/LokiTableMetadataStore.ts:22–1088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20 IServiceAdditionalProperties;
21
22export default class LokiTableMetadataStore implements ITableMetadataStore {
23 private readonly db: Loki;
24 private readonly TABLES_COLLECTION = "$TABLES_COLLECTION$";
25 private readonly SERVICES_COLLECTION = "$SERVICES_COLLECTION$";
26 private initialized: boolean = false;
27 private closed: boolean = false;
28 // The Rollback Entities arrays hold the rows that we will reapply to the database in the case
29 // that we need to rollback a transaction.
30 // We make the assumption that there will not be any IO during the processing of a transaction
31 // and assume that the execution will remain in the same thread associated with the transaction.
32 // See: https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/
33 private transactionRollbackTheseEntities: Entity[] = []; // can maybe use Entity instead of any
34 private transactionDeleteTheseEntities: Entity[] = []; // can maybe use Entity instead of any
35
36 public constructor(public readonly lokiDBPath: string, inMemory: boolean) {
37 this.db = new Loki(lokiDBPath, inMemory ? {
38 persistenceMethod: "memory"
39 } : {
40 persistenceMethod: "fs",
41 autosave: true,
42 autosaveInterval: 5000
43 });
44 }
45
46 /**
47 * Initializes the persistence layer
48 *
49 * @return {*} {Promise<void>}
50 * @memberof LokiTableMetadataStore
51 */
52 public async init(): Promise<void> {
53 await this.loadDB();
54 this.createTablesCollection();
55 this.createServicePropsCollection();
56 await this.saveDBState();
57 this.finalizeInitializationState();
58 }
59
60 /**
61 * Close down the DB
62 *
63 * @return {*} {Promise<void>}
64 * @memberof LokiTableMetadataStore
65 */
66 public async close(): Promise<void> {
67 await new Promise<void>((resolve, reject) => {
68 this.db.close((err) => {
69 if (err) {
70 reject(err);
71 } else {
72 resolve();
73 }
74 });
75 });
76
77 this.closed = true;
78 }
79

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…