diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-06-23 23:53:26 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-23 23:53:26 -0300 |
| commit | c284fcd570342c31bc21169960579a20a763e32e (patch) | |
| tree | ce7485055116d794c55090ad0978e0b3f5ff4c2a /lib/session.ml | |
| parent | b81586ee4a0543a5f9866586c78dccdd6328934a (diff) | |
| download | Sakura-c284fcd570342c31bc21169960579a20a763e32e.tar.gz Sakura-c284fcd570342c31bc21169960579a20a763e32e.zip | |
Format
Diffstat (limited to '')
| -rw-r--r-- | lib/session.ml | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/lib/session.ml b/lib/session.ml index 5505e7e..cac181f 100644 --- a/lib/session.ml +++ b/lib/session.ml @@ -4,46 +4,41 @@ DDL / DML / DRL sublanguages operate through that branch. *) module Make (NT : Nt.S) = struct - module B = Branch.Make (NT) let ( let* ) = Result.bind - class session - ~(sid : string) - ~(branch : B.branch) = - object - val mutable br : B.branch = branch - - method id = sid - method branch = br - method snapshot = br#tip - method tip = br#tip + class session ~(sid : string) ~(branch : B.branch) = + object + val mutable br : B.branch = branch + method id = sid + method branch = br + method snapshot = br#tip + method tip = br#tip - (* Switch to a different branch within the same session. *) - method set_branch (b : B.branch) = br <- b + (* Switch to a different branch within the same session. *) + method set_branch (b : B.branch) = br <- b - method close () = - let* () = br#close () in - NT.session_close sid - end + method close () = + let* () = br#close () in + NT.session_close sid + end (* Open a session on a live (mutable) branch. Creates the branch if it does not exist yet. *) let open_session claims ~branch_name = - let* sid = NT.session_open () in + let* sid = NT.session_open () in let* branch = B.open_branch claims branch_name in Ok (new session ~sid ~branch) (* Open a session pinned to a specific snapshot hash (detached / read-only). Mutations through the returned branch are refused. *) let open_snapshot_session claims ~branch_name ~snapshot_hash = - let* sid = NT.session_open () in + let* sid = NT.session_open () in let* branch = B.open_snapshot claims ~branch_name ~snapshot_hash in (* Inform RNT of the session's snapshot override so future session-path resolution (once NamespaceReferenceManager handles /system/sessions/...) can route queries through the pinned snapshot. *) - let* () = NT.session_set_branch sid branch_name snapshot_hash in + let* () = NT.session_set_branch sid branch_name snapshot_hash in Ok (new session ~sid ~branch) - end |
