grpc-rs icon indicating copy to clipboard operation
grpc-rs copied to clipboard

Expose grpc_channel_watch_connectivity_state to rust code

Open habnabit opened this issue 6 years ago • 3 comments

grpc_channel_watch_connectivity_state doesn't appear in grpc-sys even. I'll take a poke at exposing this, but I definitely haven't used the C++ level libgrpc before.

Actually, I suppose the channel isn't even exposed to the server at all right now..

habnabit avatar Oct 31 '18 05:10 habnabit

Thank you! Will look into this.

ice1000 avatar Oct 31 '18 21:10 ice1000

Question: what's your expected Rust API look like? Can you provide some examples?

Ref: https://grpc.io/grpc/core/grpc_8h.html#a568bac9fe4004c1dd790e6569b918d2f

Function description:

Watch for a change in connectivity state.

Once the channel connectivity state is different from last_observed_state, tag will be enqueued on cq with success=1. If deadline expires BEFORE the state is changed, tag will be enqueued on cq with success=0.

Function signature:

GRPCAPI void grpc_channel_watch_connectivity_state(grpc_channel* channel,
   grpc_connectivity_state last_observed_state,
   gpr_timespec deadline,
   grpc_completion_queue* cq,
   void* tag)

ice1000 avatar Oct 31 '18 21:10 ice1000

Could the callback be a trait method on service traits with an inherent empty impl? Registering callbacks is difficult, I know..

Or maybe a future? A future seems straightforward.

habnabit avatar Nov 02 '18 02:11 habnabit