dialohq / ocaml-grpc

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

Reusing connections on the client #57

Open wokalski opened 7 months ago

wokalski commented 7 months ago

ocaml-h2 does not implement goaway so it's difficult to reasonably handle rolling upgrades of gRPC servers the client is connected to. Until that is supported I am not keen to implement a higher level client abstraction.

We could use some heuristics such as rotating the connections after some time period. It's TBD but maybe such heuristics will need to be implemented anyway to be able to handle servers that don't send goaways that way.

FWIW most common implementations (i.e. the official ones) leverage GOAWAY. The first go away on sigterm and the other one when the connection si actually shutting down.

When we can intercept GOAWAYs on the client side we will be able to mark a given connection as not reusable without disrupting existing streams on that connection for a graceful shutdown procedure.

The higher level client abstraction will also need to support the following:

  1. Keepalive/ping behavior
  2. max concurrent streams
  3. Reconnects
  4. Checking readiness of the client (i.e. can it be used or not? for example the server might be down temporarily)