aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-09-26 22:29:45 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-09-26 22:29:45 -0300
commit63352e46a880985efbdfab2e539d0f4975960b94 (patch)
treec85a0c47d425d371773d7a66896e41099d2dc9ef /lib/kernel
parent504e2d03a10f1641b36a9d5f127a18bc943562ce (diff)
downloadRNT-63352e46a880985efbdfab2e539d0f4975960b94.tar.gz
RNT-63352e46a880985efbdfab2e539d0f4975960b94.zip
add session object and protocol with pinning
Diffstat (limited to '')
-rw-r--r--lib/kernel/Initialization.ml1
-rw-r--r--lib/kernel/Session.ml27
-rw-r--r--lib/kernel/Session.mli3
3 files changed, 31 insertions, 0 deletions
diff --git a/lib/kernel/Initialization.ml b/lib/kernel/Initialization.ml
index 25c2b3d..3c8addb 100644
--- a/lib/kernel/Initialization.ml
+++ b/lib/kernel/Initialization.ml
@@ -18,5 +18,6 @@ module Make (S : Abstract.Storage.STORAGE) = struct
(Ok true) evaluators
in
let* _ = Registry.update registry "evaluator" None (Some evaluator_namespace) in
+ let* _ = Registry.update registry "session" None (Some (Namespace.make ())) in
Ok root
end
diff --git a/lib/kernel/Session.ml b/lib/kernel/Session.ml
new file mode 100644
index 0000000..75bf8c9
--- /dev/null
+++ b/lib/kernel/Session.ml
@@ -0,0 +1,27 @@
+module Make (S : Abstract.Storage.STORAGE) = struct
+ module SI = Storage.Make (S)
+ module B = Branch.Make (S)
+
+ class session storage state =
+ object (self)
+ inherit Lifecycle.null
+ inherit Identity.of_id
+ method to_string = "session"
+ val storage : S.connection = storage
+ val state : Protocols.Session.state Atomic.t = Atomic.make state
+ method state = Atomic.get state
+ method pin state' = Atomic.set state state'
+ method protocols = Protocols.[Directory.make self; Session.make self]
+ method list = Ok (BatFingerTree.singleton "branch")
+
+ method find =
+ function
+ | "branch" ->
+ SI.with_read storage (fun tx ->
+ B.load tx storage (Atomic.get state).Protocols.Session.snapshot )
+ |> Result.map Option.some
+ | _ -> Ok None
+ end
+
+ let make storage state = new session storage state |> Protocols.Handle.make
+end
diff --git a/lib/kernel/Session.mli b/lib/kernel/Session.mli
new file mode 100644
index 0000000..be4451b
--- /dev/null
+++ b/lib/kernel/Session.mli
@@ -0,0 +1,3 @@
+module Make (S : Abstract.Storage.STORAGE) : sig
+ val make : S.connection -> Protocols.Session.state -> Protocols.Handle.t
+end