-
Notifications
You must be signed in to change notification settings - Fork 1.2k
tonic-web: proxy any kind of Service #1366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
LucioFranco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the change looks good to me, I left some comments. I am not super happy without this makes the router stuff a bit more complicated but I don't think we have another option.
| ResponseFuture { | ||
| case: Case::Other { | ||
| future: self.inner.call(req), | ||
| future: self.inner.call(req.map(box_body)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might be able to avoid the box if we become more generic over the incoming body type in the middleware?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's unavoidable because the middleware constructs its own bodies when it decodes the request.
the alternative would be an enum of the request body and whatever we create in GrpcWebCall I guess? Maybe that's not too bad.
|
@LucioFranco thanks for the quick review, I'll make the changes tomorrow. I'll see if I can make it backwards-compatible. |
|
@LucioFranco Please take another look
|
|
@LucioFranco could you take another look at this? |
013d34b to
3d6121e
Compare
This allows applying the GrpcWebLayer to any kind of Service, not just ones that tonic generates. This makes it possible to use tonic-web as a grpc-web proxy to a gRPC implemented in another language for example.
101fe16 to
4126d68
Compare
|
Hi @LucioFranco I'm still interested in landing this, just rebased on master could you take another look? |
|
Since tonic has been upgraded to http v1 this will obviously need a rebase, which I'll do in a new PR :) |
This allows applying the GrpcWebLayer to any kind of Service, not just ones that tonic generates. This makes it possible to use tonic-web as a grpc-web proxy to a gRPC server implemented in another language for example.
Motivation
See #1361
Solution
I made GrpcWebService generic over the request body it receives and the body that the upstream service responds. It's mostly a lot of search and replace with a couple of changes in how we convert the body to conform to the right interface.
I've also added a test that proxies to a gRPC service over a
hyper::Clientto show it's generic over any kind of Service.Closes #1361