dialohq / ocaml-grpc

gRPC library for OCaml
https://dialohq.github.io/ocaml-grpc
BSD 3-Clause "New" or "Revised" License
60 stars 9 forks source link

Async server implementation #27

Closed tmcgilchrist closed 1 year ago

tmcgilchrist commented 1 year ago

The implementation is available with this commit 2b13b10a9ff048953cb8689a25cdd22257499a48

It provides a minimal working version of server.ml for Async using Pipes with a greeter example server for testing. However if needs further testing of the other RPC types by implementing the route guide server and testing on real world examples.

This is on top of https://github.com/dialohq/ocaml-grpc/pull/25.

quernd commented 1 year ago

Wow, you’re on fire! Thank you for this contribution. I don’t have enough experience with Async unfortunately. Would you be willing to take a look @mbacarella ?

tmcgilchrist commented 1 year ago

Thanks. I’m not sure the types of the Pipe on the streaming type signatures are quite right. Please hold off on merging while I do some more research.

On Sat, 13 May 2023 at 6:02 pm, Daniel Quernheim @.***> wrote:

Wow, you’re on fire! Thank you for this contribution. I don’t have enough experience with Async unfortunately. Would you be willing to take a look @mbacarella https://github.com/mbacarella ?

— Reply to this email directly, view it on GitHub https://github.com/dialohq/ocaml-grpc/pull/27#issuecomment-1546591447, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABJXOLMOAX2FKU4I3PGL5TXF453FANCNFSM6AAAAAAXTW7FZA . You are receiving this because you authored the thread.Message ID: @.***>

tmcgilchrist commented 1 year ago

I am happier with this version @mbacarella. The types in server.mli are more obviously correct now:

  type unary = string -> (Grpc.Status.t * string option) Deferred.t
  (** [unary] is the type for a unary grpc rpc, one request, one response. *)

  type client_streaming =
    string Pipe.Reader.t -> (Grpc.Status.t * string option) Deferred.t
  (** [client_streaming] is the type for an rpc where the client streams the requests and the server responds once. *)

  type server_streaming =
    string -> string Pipe.Writer.t -> Grpc.Status.t Deferred.t
  (** [server_streaming] is the type for an rpc where the client sends one request and the server sends multiple responses. *)

  type bidirectional_streaming =
    string Pipe.Reader.t -> string Pipe.Writer.t -> Grpc.Status.t Deferred.t
  (** [bidirectional_streaming] is the type for an rpc where both the client and server can send multiple messages. *)

There is a route guide implementation using Async that works using Pipe.t it might have some mistakes, I haven't used Pipe.t before.

tmcgilchrist commented 1 year ago

The failure on debian-12-5.1 should be fixed soon. Core.v0.16.0 is not compatible with OCaml 5.1.