Hi, we have an Eio based http2/grpc client. Let’s assume we are creating a tcp socket in a switch, and when that switch finishes we want to wait for all writes to finish and write a Goaway to the other side, something analogous to triggering a cleanup on Sigint for the entire program. That said we want to leave the TCP socket open during that time.
It seems like there’s no natural way to handle it in eio.
I would want something like this:
Eio.Switch.run @@ fun sw ->
let socket = Eio.Net.connect ~sw ... in
run_client socket;
run_client socket
And after the second run_client
returns (that is switch’s fn returns) I want to wait for the writes to finish and maybe do some cleanup before the socket is closed. The socket is closed in on_release
.
Am I seeing correctly that the behavior I’m thinking about here is impossible to implement with the current APIs? Could we simply add another list of callbacks to switche’s state like before_release
or whatever and put it here?
I am aware I can use a mixture of a child Switch and Cancel.protect to sort of achieve this but this puts a lot of burden on the users of my API and makes the entire program much more complex.