Hi there!
I've come across an issue (that is well described by this
issue) that is impacting my usage of gRPC with ruby and I'm now working on a PR to fix the problem. To summarize - the ruby
interceptor proposal indicates that gRPC responses may be accessed/modified within an interceptor, when neither is true currently (as described in the linked issue). There's also a
relevant comment on the implementing PR indicating why this may be the case. gRPC interceptors in other languages work this way - allowing responses to be inspected/modified. Without this functionality, ruby gRPC interceptors only currently provide half the functionality as interceptors in other languages.
I've started working on a solution, and would like to solicit some suggestions for the approach. I noticed that there is no top level object describing the gRPC response. It seems the ruby version of the protobuf response is returned from this call
here and then
here a collection of grpc_ops is generated and sent to
run_batch. It seems in order to allow interceptors access to the response, the items composing the ops will need to be wrapped in some sort of structure. I'm also anticipating that instead of calling
active_call.server_unary_response within the block passed to the interceptors, we can instead get the response from the inter_ctx.intercept! call (since interceptors will now need to return the response), and then invoke the actual network response instead, allowing any interceptor in the chain to make modifications or inspect the response, before it is sent.
My questions are:
1) is this approach reasonable?
2) where would a gRPC response class fit in well? is there anything it needs besides payload, status, and metadata? Any thoughts on naming?
Thanks,
Michelle