mirror of
https://github.com/zap-proto/ocaml-rpc.git
synced 2026-10-30 15:04:28 +00:00
The original idea was to allow different async libraries to be used, but with effects we should only ever need one library, so it makes sense to use the shorter `Capnp_rpc` name for this. The core protocol is now a sub-library of the same package (`capnp-rpc.proto`). The protocol modules that are generally useful are now re-exported by the new `Capnp_rpc`. This change is useful on its own, but the main aim is to reduce the diff when switching from Lwt to Eio.
25 lines
642 B
OCaml
25 lines
642 B
OCaml
module Api = Api.MakeRPC(Capnp_rpc)
|
|
|
|
open Capnp_rpc.Std
|
|
|
|
let local label =
|
|
let module Logger = Api.Service.Logger in
|
|
Logger.local @@ object
|
|
inherit Logger.service
|
|
|
|
method log_impl params release_param_caps =
|
|
let open Logger.Log in
|
|
let msg = Params.msg_get params in
|
|
release_param_caps ();
|
|
Printf.printf "[server] %S says %S\n%!" label msg;
|
|
Service.return_empty ()
|
|
end
|
|
|
|
module Logger = Api.Client.Logger
|
|
|
|
let log t msg =
|
|
let open Logger.Log in
|
|
let request, params = Capability.Request.create Params.init_pointer in
|
|
Params.msg_set params msg;
|
|
Capability.call_for_unit_exn t method_id request
|