tonic icon indicating copy to clipboard operation
tonic copied to clipboard

feat(grpc-web): make public some methods to enable grpc-web client proxying

Open zakhenry opened this issue 1 year ago • 2 comments

Motivation

I want to create a middleware grpc service that can listen to regular grpc calls, and forward them to another service as grpc-web calls. In order to do this fully generically, there needs to be made public some internals of tonic that are normally called via the Grpc service that the generated service code uses.

Solution

Publish the minimal set of symbols that are required


If there is interest, I can create a new example in the examples dir to demonstrate grpc-web proxying. I've only tested unary calls locally so far.

zakhenry avatar Aug 23 '24 08:08 zakhenry

relates to #31 but doesn't necessarily close it. update: it probably does close that issue as I've used this branch for both grpc-web and IPC handling for my project with success

zakhenry avatar Aug 23 '24 08:08 zakhenry

Marked as ready for review, but note it is not ready for merge as it needs docs on the newly public interfaces and possible an example of use. Just want to make sure the concept is sound before I put further effort in.

zakhenry avatar Aug 27 '24 17:08 zakhenry

I think these changes are okay (once CI passes), but would be interested in feedback from @tottoto.

djc avatar Aug 28 '24 13:08 djc

Looks good to me too.

If there is interest, I can create a new example in the examples dir to demonstrate grpc-web proxying. I've only tested unary calls locally so far.

I would think it would be helpful. Would appreciate your suggestion, but we need to see the actual example to consider whether to add it.

tottoto avatar Aug 28 '24 14:08 tottoto

@tottoto thanks for the review, I've fixed up the CI with some docs, and added a new example demonstrating a super basic proxy that just passes a request on. Of course my real world proxy does more things like grpc-web translation but I wanted to keep it smallish.

zakhenry avatar Aug 30 '24 02:08 zakhenry

I don't think we want to add yet another example here. Would be good to get the documentation additions squashed into the initial commit, though.

djc avatar Aug 30 '24 09:08 djc

@djc I understand the resistance to the proliferation of too many examples though since this one touches these newly public api do you reckon I'd be better of reformulating the example as an integration test?

zakhenry avatar Aug 30 '24 20:08 zakhenry

For now, I've dropped the example from this PR entirely so we can get this in and continue discussion in another PR if that's a preferred option?

zakhenry avatar Aug 30 '24 20:08 zakhenry

I think the remaining CI failure is fixed by #1906

zakhenry avatar Aug 31 '24 02:08 zakhenry

@tottoto any chance you could have another look at this PR? Thanks!

zakhenry avatar Sep 02 '24 14:09 zakhenry