Decides, per entity, whether an event is the newest one, and records it if so. Construct it next to the store it uses; it holds no state of its own.
const decision = await guard.advance({ scope: "github", id: issue.node_id, version: [updatedAtMs, deliverySeq], kind: "write" });if (decision === "apply") await saveIssue(issue); Copy
const decision = await guard.advance({ scope: "github", id: issue.node_id, version: [updatedAtMs, deliverySeq], kind: "write" });if (decision === "apply") await saveIssue(issue);
Decides and records one event. On apply, make your write; run this in the same transaction as that write when your store can. An error from the store is rethrown unchanged.
apply
Decides, per entity, whether an event is the newest one, and records it if so. Construct it next to the store it uses; it holds no state of its own.