MCPcopy Create free account
hub / github.com/apache/maka / withStore

Function withStore

packages/storage/src/__tests__/sqlite-runtime-store.test.ts:1753–1776  ·  view source on GitHub ↗
(
  run: (
    store: Store,
    dbPath: string,
    setFailpoint: (point: SqliteRuntimeStoreFailpoint | undefined) => void,
  ) => Promise<void>,
)

Source from the content-addressed store, hash-verified

1751type Store = ReturnType<typeof createSqliteRuntimeStore>;
1752
1753async function withStore(
1754 run: (
1755 store: Store,
1756 dbPath: string,
1757 setFailpoint: (point: SqliteRuntimeStoreFailpoint | undefined) => void,
1758 ) => Promise<void>,
1759): Promise<void> {
1760 const root = await mkdtemp(join(tmpdir(), 'maka-sqlite-runtime-'));
1761 const dbPath = join(root, 'runtime.sqlite');
1762 let failpoint: SqliteRuntimeStoreFailpoint | undefined;
1763 const store = createSqliteRuntimeStore(dbPath, {
1764 failpoint: (point) => {
1765 if (failpoint === point) throw new Error(`sqlite runtime failpoint: ${point}`);
1766 },
1767 });
1768 try {
1769 await run(store, dbPath, (point) => {
1770 failpoint = point;
1771 });
1772 } finally {
1773 store.close();
1774 await rm(root, { recursive: true, force: true });
1775 }
1776}
1777
1778function continuationClaim(
1779 input: Parameters<typeof continuationClaimForBoundary>[1] = {},

Callers 1

Calls 4

createSqliteRuntimeStoreFunction · 0.85
rmFunction · 0.85
closeMethod · 0.65
runFunction · 0.50

Tested by

no test coverage detected