Skip to content

Commit

Permalink
fix in memory metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
kyscott18 committed Jun 13, 2024
1 parent 337021c commit 7f9168b
Show file tree
Hide file tree
Showing 3 changed files with 305 additions and 276 deletions.
81 changes: 37 additions & 44 deletions packages/core/src/_test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,36 +160,33 @@ export async function setupDatabaseServices(
common: context.common,
});

const indexingStore = {
...getReadonlyStore({
encoding: "sqlite",
schema: config.schema,
namespaceInfo: result.namespaceInfo,
db: database.indexingDb,
}),
...(config.indexing === "historical"
const readonlyStore = getReadonlyStore({
encoding: "sqlite",
schema: config.schema,
namespaceInfo: result.namespaceInfo,
db: database.indexingDb,
});

const indexingStore =
config.indexing === "historical"
? getHistoricalStore({
encoding: "sqlite",
schema: config.schema,
readonlyStore,
namespaceInfo: result.namespaceInfo,
db: database.indexingDb,
common: context.common,
isCacheExhaustive: true,
})
: getRealtimeStore({
encoding: "sqlite",
schema: config.schema,
namespaceInfo: result.namespaceInfo,
db: database.indexingDb,
})),
};

const readonlyStore = getReadonlyStore({
encoding: "sqlite",
schema: config.schema,
namespaceInfo: result.namespaceInfo,
db: database.readonlyDb,
});
: {
...readonlyStore,
...getRealtimeStore({
encoding: "sqlite",
schema: config.schema,
namespaceInfo: result.namespaceInfo,
db: database.indexingDb,
}),
};

const cleanup = () => database.kill();

Expand All @@ -216,37 +213,33 @@ export async function setupDatabaseServices(
db: database.syncDb,
common: context.common,
});
const readonlyStore = getReadonlyStore({
encoding: "postgres",
schema: config.schema,
namespaceInfo: result.namespaceInfo,
db: database.indexingDb,
});

const indexingStore = {
...getReadonlyStore({
encoding: "postgres",
schema: config.schema,
namespaceInfo: result.namespaceInfo,
db: database.indexingDb,
}),
...(config.indexing === "historical"
const indexingStore =
config.indexing === "historical"
? getHistoricalStore({
encoding: "postgres",
schema: config.schema,
readonlyStore,
namespaceInfo: result.namespaceInfo,
db: database.indexingDb,
common: context.common,
isCacheExhaustive: true,
})
: getRealtimeStore({
encoding: "postgres",
schema: config.schema,
namespaceInfo: result.namespaceInfo,
db: database.indexingDb,
})),
};

const readonlyStore = getReadonlyStore({
encoding: "postgres",
schema: config.schema,
namespaceInfo: result.namespaceInfo,
db: database.readonlyDb,
});
: {
...readonlyStore,
...getRealtimeStore({
encoding: "postgres",
schema: config.schema,
namespaceInfo: result.namespaceInfo,
db: database.indexingDb,
}),
};

const cleanup = () => database.kill();

Expand Down
18 changes: 3 additions & 15 deletions packages/core/src/bin/utils/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,14 @@ export async function run({
const historicalStore = getHistoricalStore({
encoding: database.kind,
schema,
readonlyStore,
namespaceInfo,
db: database.indexingDb,
common,
isCacheExhaustive: isCheckpointEqual(zeroCheckpoint, initialCheckpoint),
});

let indexingStore: IndexingStore = {
...getReadonlyStore({
encoding: database.kind,
schema,
namespaceInfo,
db: database.indexingDb,
}),
...historicalStore,
};
let indexingStore: IndexingStore = historicalStore;

const indexingService = createIndexingService({
indexingFunctions,
Expand Down Expand Up @@ -288,12 +281,7 @@ export async function run({
});

indexingStore = {
...getReadonlyStore({
encoding: database.kind,
schema,
namespaceInfo,
db: database.indexingDb,
}),
...readonlyStore,
...getRealtimeStore({
encoding: database.kind,
schema,
Expand Down
Loading

0 comments on commit 7f9168b

Please sign in to comment.