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

Function chainWrite

packages/storage/src/write-queue.ts:11–26  ·  view source on GitHub ↗
(
  queueMap: Map<string, Promise<void>>,
  key: string,
  operation: () => Promise<void>,
)

Source from the content-addressed store, hash-verified

9 * the chain alive for subsequent writes.
10 */
11export function chainWrite(
12 queueMap: Map<string, Promise<void>>,
13 key: string,
14 operation: () => Promise<void>,
15): Promise<void> {
16 const previous = queueMap.get(key) ?? Promise.resolve();
17 const next = previous.then(operation, operation);
18 const stored = next.catch(() => {
19 // Keep the chain alive after failures.
20 });
21 const tracked = stored.finally(() => {
22 if (queueMap.get(key) === tracked) queueMap.delete(key);
23 });
24 queueMap.set(key, tracked);
25 return next;
26}

Callers 14

readOperationReceiptMethod · 0.85
mutateOptionalMethod · 0.85
purgeSessionStateMethod · 0.85
mutateMethod · 0.85
purgeSessionStateMethod · 0.85
mutateMethod · 0.85
createMethod · 0.85
updateMethod · 0.85
archiveMethod · 0.85
unarchiveMethod · 0.85

Calls 4

getMethod · 0.65
resolveMethod · 0.65
deleteMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected