summaryrefslogtreecommitdiff
path: root/ocaml/lib/eventlog_lmdb.mli
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-20 13:13:39 +0700
committerpolwex <polwex@sortug.com>2025-10-20 13:13:39 +0700
commitd21900836f89b2bf9cd55ff1708a4619c8b89656 (patch)
treebb3a5842ae408ffa465814c6bbf27a5002866252 /ocaml/lib/eventlog_lmdb.mli
neoinityes
Diffstat (limited to 'ocaml/lib/eventlog_lmdb.mli')
-rw-r--r--ocaml/lib/eventlog_lmdb.mli35
1 files changed, 35 insertions, 0 deletions
diff --git a/ocaml/lib/eventlog_lmdb.mli b/ocaml/lib/eventlog_lmdb.mli
new file mode 100644
index 0000000..1369ed6
--- /dev/null
+++ b/ocaml/lib/eventlog_lmdb.mli
@@ -0,0 +1,35 @@
+(** LMDB-based event log (matches Vere's implementation) *)
+
+type event_num = int64
+(** Event number (1-indexed) *)
+
+type t
+(** Event log handle *)
+
+val create : ?enabled:bool -> string -> t
+(** [create ?enabled pier_path] opens or creates an event log at [pier_path/.urb/log].
+ If [enabled] is false, events are not persisted (default: true).
+ Uses LMDB with two databases: "EVENTS" and "META". *)
+
+val close : t -> unit
+(** [close log] syncs and closes the event log *)
+
+val append : ?verbose:bool -> t -> Noun.noun -> event_num
+(** [append ?verbose log noun] appends [noun] to the log and returns its event number.
+ Events are serialized as: 4-byte mug + jammed noun. *)
+
+val read_event : ?verbose:bool -> t -> event_num -> Noun.noun
+(** [read_event ?verbose log event_num] reads event [event_num] from the log *)
+
+val gulf : t -> (event_num * event_num) option
+(** [gulf log] returns [(first, last)] event numbers in the log, or None if empty *)
+
+val replay : ?verbose:bool -> t -> (event_num -> Noun.noun -> unit) -> unit
+(** [replay ?verbose log callback] replays all events in the log, calling
+ [callback event_num noun] for each event *)
+
+val last_event : t -> event_num
+(** [last_event log] returns the last event number in the log *)
+
+val sync : t -> unit
+(** [sync log] syncs the log to disk *)