Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dependencies for eio and async #47

Merged
merged 5 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
(depends
(grpc
(= :version))
eio
(eio (>= 0.12))
stringext))

(package
Expand All @@ -96,7 +96,7 @@
tls-async
(lwt_ssl (>= 1.2.0))
(mdx (and (>= 2.2.1) :with-test))
(eio_main (>= 0.10))
(eio_main (>= 0.12))
stringext))

(package
Expand Down
3 changes: 1 addition & 2 deletions examples/greeter-client-eio/greeter_client_eio.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ let main env =
let addr = `Tcp (Eio_unix.Net.Ipaddr.of_unix inet, port) in
let socket = Eio.Net.connect ~sw network addr in
let connection =
H2_eio.Client.create_connection ~sw ~error_handler:ignore
(socket :> Eio.Flow.two_way)
H2_eio.Client.create_connection ~sw ~error_handler:ignore socket
in

let open Ocaml_protoc_plugin in
Expand Down
3 changes: 1 addition & 2 deletions examples/greeter-server-eio/greeter_server_eio.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ let connection_handler server sw =
in
fun socket addr ->
H2_eio.Server.create_connection_handler ?config:None ~request_handler
~error_handler addr
(socket :> Eio.Flow.two_way)
~error_handler addr ~sw socket

let serve server env =
let port = 8080 in
Expand Down
2 changes: 1 addition & 1 deletion examples/routeguide-async/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
core
core_unix.command_unix
routeguide_proto_async
h2-lwt-unix
h2-async
yojson
ppx_deriving_yojson.runtime)
(preprocess
Expand Down
7 changes: 3 additions & 4 deletions examples/routeguide-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ Now let's look at something a little more complicated: the client-side streaming

<!-- $MDX include,file=routeguide/src/server.ml,part=server-record-route -->
```ocaml
let record_route (clock : #Eio.Time.clock) (stream : string Seq.t) =
let record_route (clock : _ Eio.Time.clock) (stream : string Seq.t) =
Eio.traceln "RecordRoute";

let last_point = ref None in
Expand Down Expand Up @@ -378,7 +378,7 @@ let serve server env =
let clock = Eio.Stdenv.clock env in
let addr = `Tcp (Eio.Net.Ipaddr.V4.loopback, port) in
Eio.Switch.run @@ fun sw ->
let handler = connection_handler (server clock) sw in
let handler = connection_handler ~sw (server clock) in
let server_socket =
Eio.Net.listen net ~sw ~reuse_addr:true ~backlog:10 addr
in
Expand Down Expand Up @@ -425,8 +425,7 @@ let client ~sw host port network =
in
let addr = `Tcp (Eio_unix.Net.Ipaddr.of_unix inet, port) in
let socket = Eio.Net.connect ~sw network addr in
H2_eio.Client.create_connection ~sw ~error_handler:ignore
(socket :> Eio.Flow.two_way)
H2_eio.Client.create_connection ~sw ~error_handler:ignore socket
```

To call service methods, we take the H2 connection and build up a gRPC call for the service method using `Client.call` from the Client module.
Expand Down
3 changes: 1 addition & 2 deletions examples/routeguide/src/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ let client ~sw host port network =
in
let addr = `Tcp (Eio_unix.Net.Ipaddr.of_unix inet, port) in
let socket = Eio.Net.connect ~sw network addr in
H2_eio.Client.create_connection ~sw ~error_handler:ignore
(socket :> Eio.Flow.two_way)
H2_eio.Client.create_connection ~sw ~error_handler:ignore socket

(* $MDX part-end *)
(* $MDX part-begin=client-get-feature *)
Expand Down
9 changes: 4 additions & 5 deletions examples/routeguide/src/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ let list_features (buffer : string) (f : string -> unit) =

(* $MDX part-end *)
(* $MDX part-begin=server-record-route *)
let record_route (clock : #Eio.Time.clock) (stream : string Seq.t) =
let record_route (clock : _ Eio.Time.clock) (stream : string Seq.t) =
Eio.traceln "RecordRoute";

let last_point = ref None in
Expand Down Expand Up @@ -221,7 +221,7 @@ let server clock =
~service:(route_guide_service clock))

(* $MDX part-end *)
let connection_handler server sw =
let connection_handler server ~sw =
let error_handler client_address ?request:_ _error start_response =
Eio.traceln "Error in request from:%a" Eio.Net.Sockaddr.pp client_address;
let response_body = start_response H2.Headers.empty in
Expand All @@ -235,8 +235,7 @@ let connection_handler server sw =
in
fun socket addr ->
H2_eio.Server.create_connection_handler ?config:None ~request_handler
~error_handler addr
(socket :> Eio.Flow.two_way)
~error_handler addr socket ~sw

(* $MDX part-begin=server-main *)
let serve server env =
Expand All @@ -245,7 +244,7 @@ let serve server env =
let clock = Eio.Stdenv.clock env in
let addr = `Tcp (Eio.Net.Ipaddr.V4.loopback, port) in
Eio.Switch.run @@ fun sw ->
let handler = connection_handler (server clock) sw in
let handler = connection_handler ~sw (server clock) in
let server_socket =
Eio.Net.listen net ~sw ~reuse_addr:true ~backlog:10 addr
in
Expand Down
2 changes: 1 addition & 1 deletion grpc-eio.opam
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bug-reports: "https://github.com/dialohq/ocaml-grpc/issues"
depends: [
"dune" {>= "3.7"}
"grpc" {= version}
"eio"
"eio" {>= "0.12"}
"stringext"
"odoc" {with-doc}
]
Expand Down
2 changes: 1 addition & 1 deletion grpc-examples.opam
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ depends: [
"tls-async"
"lwt_ssl" {>= "1.2.0"}
"mdx" {>= "2.2.1" & with-test}
"eio_main" {>= "0.10"}
"eio_main" {>= "0.12"}
"stringext"
"odoc" {with-doc}
]
Expand Down
2 changes: 1 addition & 1 deletion lib/grpc-async/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(library
(name grpc_async)
(public_name grpc-async)
(libraries grpc h2 h2-async stringext async)
(libraries grpc h2 stringext async)
(preprocess
(pps ppx_jane)))
2 changes: 1 addition & 1 deletion lib/grpc-eio/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(library
(name grpc_eio)
(public_name grpc-eio)
(libraries grpc h2-eio))
(libraries grpc h2 eio))