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

Question: purpose of the `Grpc.Status.t` returned with the `Ok` case. #39

Open clembu opened 1 year ago

clembu commented 1 year ago

Hello everyone. I'm wondering why there's a status tupled with the rpc response, as a return to Client.call.

All the examples end up matching the result with

match response with
| Ok (response, _ok) -> ...
| Error error -> ...

As there are no examples showing a use case for this status, and all existing examples end up ignoring it, I am left wondering why it is given at all. Are there any cases where it is not the OK status? If so, which values can it be?

quernd commented 1 year ago

Thanks for bringing this up! These are gRPC specific status codes. It is not necessarily the OK status, and it's up to you to handle it or not.

You're right, it would be good not to ignore this code in the examples. Feel free to modify the examples and open a PR, otherwise we'll get to it some time soon.

tmcgilchrist commented 1 year ago

An interesting example to add would be support for the gRPC health check API and implement a scenario like pausing calling a service when the health check stops responding then resuming when it is healthy again. I made an earlier start on it here https://github.com/tmcgilchrist/ocaml-grpc/tree/grpc_health_check with a view to implementing this example from Rust https://github.com/hyperium/tonic/tree/master/examples/src/health