this repo has no description
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

create works + try to make the file capability persistent

+26 -30
+3 -1
mvp/ocaml/client/client.ml
··· 8 8 Capnp_rpc_unix.with_cap_exn client f 9 9 10 10 let pp_name ppf name = Fmt.pf ppf "%a" Fmt.(styled `Bold string) name 11 - let pp_entry ppf entry = pp_name ppf entry.Storage.name 11 + 12 + let pp_entry ppf { Storage.name; file } = 13 + Fmt.pf ppf "%a:%a" pp_name name Capability.pp file 12 14 13 15 let ls net () uri = 14 16 connect net uri @@ fun dir ->
+9 -24
mvp/ocaml/client/storage.ml
··· 23 23 let open API.Client.Directory.Create in 24 24 let request, params = Capability.Request.create Params.init_pointer in 25 25 Params.name_set params name; 26 - let results = Capability.call_for_value_exn t method_id request in 27 - match Results.file_get results with 28 - | Some file -> file 29 - | None -> failwith "Storage.create: no file returned" 26 + Capability.call_for_caps t method_id request Results.file_get_pipelined 30 27 31 28 let open_ t name = 32 29 let open API.Client.Directory.Open in ··· 47 44 let results = Capability.call_for_value_exn t method_id request in 48 45 Stdint.Int64.of_uint64 (Results.size_get results) 49 46 47 + let opt_set f params = function 48 + | None -> () 49 + | Some n -> f params (Stdint.Int64.to_uint64 n) 50 + 50 51 let read ?off ?len t = 51 52 let open API.Client.File.Read in 52 53 let request, params = Capability.Request.create Params.init_pointer in 53 - let () = 54 - match off with 55 - | None -> () 56 - | Some off -> Params.off_set params (Stdint.Int64.to_uint64 off) 57 - in 58 - let () = 59 - match len with 60 - | None -> () 61 - | Some len -> Params.len_set params (Stdint.Int64.to_uint64 len) 62 - in 54 + opt_set Params.off_set params off; 55 + opt_set Params.len_set params len; 63 56 let results = Capability.call_for_value_exn t method_id request in 64 57 Results.data_get results 65 58 66 59 let write ?off ?len t d = 67 60 let open API.Client.File.Write in 68 61 let request, params = Capability.Request.create Params.init_pointer in 69 - let () = 70 - match off with 71 - | None -> () 72 - | Some off -> Params.off_set params (Stdint.Int64.to_uint64 off) 73 - in 74 - let () = 75 - match len with 76 - | None -> () 77 - | Some len -> Params.len_set params (Stdint.Int64.to_uint64 len) 78 - in 62 + opt_set Params.off_set params off; 63 + opt_set Params.len_set params len; 79 64 Params.data_set params d; 80 65 Capability.call_for_unit_exn t method_id request
+2 -2
mvp/ocaml/server/directory.ml
··· 1 1 open Capnp_rpc.Std 2 2 module API = Schema.Storage.MakeRPC (Capnp_rpc) 3 3 4 - let local dir = 4 + let local sr dir = 5 5 let module Directory = API.Service.Directory in 6 - Directory.local 6 + Capnp_rpc.Persistence.with_sturdy_ref sr Directory.local 7 7 @@ object 8 8 inherit Directory.service 9 9
+4 -1
mvp/ocaml/server/directory.mli
··· 1 1 open Capnp_rpc 2 2 open Bellairs 3 3 4 - val local : Impl.dir -> API.Service.Directory.t Capability.t 4 + val local : 5 + API.Service.Directory.t Sturdy_ref.t -> 6 + Impl.dir -> 7 + API.Service.Directory.t Capability.t
+8 -2
mvp/ocaml/server/server.ml
··· 5 5 6 6 let serve () config = 7 7 Switch.run @@ fun sw -> 8 + let make_sturdy = Capnp_rpc_unix.Vat_config.sturdy_uri config in 9 + let services = Restorer.Table.create ~sw make_sturdy in 10 + let restore = Restorer.of_table services in 8 11 let root_id = Capnp_rpc_unix.Vat_config.derived_id config "root" in 9 - let root = Impl.root () in 10 - let restore = Restorer.single root_id (Directory.local root) in 12 + let root = 13 + let sr = Capnp_rpc_net.Restorer.Table.sturdy_ref services root_id in 14 + Directory.local sr (Impl.root ()) 15 + in 16 + Restorer.Table.add services root_id root; 11 17 let vat = Capnp_rpc_unix.serve ~sw ~restore config in 12 18 match Capnp_rpc_unix.Cap_file.save_service vat root_id cap_file with 13 19 | Error (`Msg m) -> failwith m