EIO with any RPC library

Hi,

I use OCaml 5 and failed to compile Thrift because the bindings require an earlier version of the compiler.

I am now trying to use capnp and it is based on Lwt. Believe it should be possible to use with eio. Are there examples ?

This is my first time. Are there any modern RPC libraries ?
I should adopt this approach ?

Mohan

If you are not tied to capnp, you can also add ocaml-grpc to your study. It has a Eio backend available. Generally speaking, I’m interested about Eio+RPC as well (did some experiment with ocaml-grpc here).

I’d like to explore jsonrpc options too but didn’t get a chance to do it yet. Is there any option out there? The RPC lib used in dune looks great, however it has its own scheduler. I looked a bit into it here and I’d be curious to learn more.

3 Likes

Hey @Mohan_Radhakrishnan,

@talex5 has already got a very comprehensive port of Capnp from Lwt to Eio: Initial Eio port by talex5 · Pull Request #256 · mirage/capnp-rpc · GitHub – note this is a direct port, not using Lwt_eio. I’ve had success building things from this branch.

Slightly confusingly this is still available under the library capnp-rpc-lwt.

Hi, the last published Thrift package requires OCaml <5 but the master branch has been updated since then and should work with OCaml 5+. You can try pinning it directly from GitHub: GitHub - vbmithr/ocaml-thrift-lib: Thrift library for OCaml extracted from Thrift sources

1 Like

I am going through the examples from this branch. Will try this.

Update : My simple RPC works.

  Lwt_main.run begin
    let service = Server.local in
    Client.ping service "foo" >>= fun reply ->
    Fmt.pr "Got reply %S@." reply;
    Lwt.return_unit
  end

The references to LWT are temporary. I presume.

Thanks.

Here’s a first step to sorting that out: Rename capnp-rpc-lwt package to capnp-rpc by talex5 · Pull Request #280 · mirage/capnp-rpc · GitHub

1 Like

Isn’t capnp-rpc/examples/v2/echo.ml at eio · mirage/capnp-rpc · GitHub the branch to be pinned ?
Am I looking at the right example ?

Thanks.

I’d forgotten about that branch! Now deleted to avoid confusion.

I’ve applied the rename now, so the _lwt is gone (from both the Lwt and Eio versions).

I see. I may be missing the point here. I thought all dependencies on Lwt will be removed and only eio will be used henceforth. That means the entire RPC library will only need eio APIs ??

let connect uri =
Lwt_main.run begin
let client_vat = Capnp_rpc_unix.client_only_vat () in
let sr = Capnp_rpc_unix.Vat.import_exn client_vat uri in
Capnp_rpc_unix.with_cap_exn sr run_client
end

This code in this file means something else ?

Thanks.

That’s from the master branch, which uses Lwt.

The Eio branch is here:

I’ll probably merge some or all of it in the next few days.

1 Like

This is now all merged, and my eio branch has been deleted.

1 Like