aboutsummaryrefslogtreecommitdiffstats
path: root/prototypes/connections/state.h
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-25 15:37:53 +0100
committereunhhu <[email protected]>2026-09-25 15:37:53 +0100
commit49c29a1255e1ad3f7fde6c64910c7d2c38edad78 (patch)
tree7f76ee0913526dff84a69135e61e3a9cd3c01c64 /prototypes/connections/state.h
parent2ae802cfaa3dae01627d4c80e2655fb5e69f4e1e (diff)
downloadpure-49c29a1255e1ad3f7fde6c64910c7d2c38edad78.tar.gz
pure-49c29a1255e1ad3f7fde6c64910c7d2c38edad78.zip
Commit several drafts of the tree store atomically
pure_draft_commit_all publishes drafts of one store with a single head: every key must still be at its draft's base revision, all new extents and catalog records are written and synced once, and either every document becomes visible or none does. A single draft commit is the one-draft case. pure_state_open stores runtime-owned values (app states) under '.' plus a key. Document keys never start with '.', listings skip these values, and document operations refuse their names, so an app's state cannot collide with a document a client names. Tests kill a process at every commit stage of a three-draft batch and see all or none, inject each fault, stop a batch on one stale draft, and commit fifty keys in no order at once.
Diffstat (limited to 'prototypes/connections/state.h')
-rw-r--r--prototypes/connections/state.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/prototypes/connections/state.h b/prototypes/connections/state.h
index 461f71a..55ad257 100644
--- a/prototypes/connections/state.h
+++ b/prototypes/connections/state.h
@@ -17,6 +17,10 @@ typedef struct PureDraft PureDraft;
PureDraft *pure_draft_new(void);
/* A missing key opens as an empty draft at revision 0; commit creates it. */
PureResult pure_draft_open(const char *path, const char *key, PureDraft **out);
+/* A runtime-owned value of an app, such as a list or text state, stored
+ * under a name that is never a document key (hosts listing documents do not
+ * see it). name is a valid key of at most 63 bytes. */
+PureResult pure_state_open(const char *path, const char *name, PureDraft **out);
/* Memory only. Fails without change on a bad range or when memory runs out. */
PureResult pure_draft_splice(PureDraft *, size_t offset, size_t remove, PureSpan insert);
size_t pure_draft_size(const PureDraft *);
@@ -40,5 +44,9 @@ void pure_draft_restore(PureDraft *, PureVersion);
/* Publish if the key is still at the draft's base revision. On success the
* draft continues from the new revision; on any failure it is unchanged. */
PureResult pure_draft_commit(PureDraft *, int64_t *revision);
+/* Publish drafts of one store in one commit: each key must still be at its
+ * draft's base revision (a conflict names the stored revision in revisions),
+ * and either every draft is published or none is. Keys must differ. */
+PureResult pure_draft_commit_all(PureDraft *const *drafts, size_t count, int64_t *revisions);
void pure_draft_close(PureDraft *);
#endif