-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add a register, so that the gRPC service can be invoked in-process to provide a HTTP server. #947
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Hi @hb-chen! Thanks for your PR. This is an interesting new feature! You'll need to regenerate all the example files with this template change: https://github.com/grpc-ecosystem/grpc-gateway/blob/master/CONTRIBUTING.md#i-want-to-regenerate-the-files-after-making-changes. |
I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
When I try to support stream, I see the PR(grpc/grpc-go#906 (comment)) of grpc-go, will support for In-Process transport. And now I use buffconn. grpc/grpc-go#1263 (comment)
|
Seems like the latest version of the generated files have some compilation errors - I assume this is due to a small problem in the template. Could you take another look please? |
+1 for this feature. Much appreciated |
+1 |
@hb-chen I'd be happy to merge initial support for just unary requests. What do you think? |
I agree with you. |
@hb-chen Any progress on this? |
+1 |
Just bazel check failed. |
@hb-chen, thanks so much for doing this! Looks like I need to push an update to the rules_go stuff to make Bazel work. One moment please. Would you be willing to wait for that PR (I'll mention this one in it) and then rebase off master? |
@hb-chen, if you could rebase off of master I think this will pass CI. Thanks so much! |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
||
client := New{{$svc.GetName}}Client(conn) | ||
{{end}} | ||
|
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.
Move this newline before the {{end}}
to avoid a newline at the top of non streaming services.
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.
On line 579 have streaming condition {{if eq $streaming 1}}
.
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.
Since we decided not to support streaming endpoints fort now, can we remove this?
Co-Authored-By: Johan Brandhorst <johan.brandhorst@gmail.com>
Co-Authored-By: Johan Brandhorst <johan.brandhorst@gmail.com>
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.
Let's remove the streaming specific code until it's implemented by gRPC.
|
||
client := New{{$svc.GetName}}Client(conn) | ||
{{end}} | ||
|
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.
Since we decided not to support streaming endpoints fort now, can we remove this?
// Register{{$svc.GetName}}{{$.RegisterFuncSuffix}}Server registers the http handlers for service {{$svc.GetName}} to "mux". | ||
// UnaryRPC :call {{$svc.GetName}}Server directly. | ||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. | ||
// If the gateway proto have stream must add DialOption grpc.WithContextDialer. e.g. |
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.
Please remove the comments below this line.
The new template changes look great, just a quick thought; do you think we could add a test case to the integration tests that calls the unary methods? It shouldn't be too hard, hopefully. Just a sanity test that the new functionality works. |
@hb-chen I don't want to lose sight of this, would you be able to write the tests or would you like to merge this as is? |
tks, I will write tests. |
OK I see we have some tests, I think we can merge this! |
Oops, the func have an error, opts []grpc.DialOption is unused. |
Hm, it would be a backward compatibility breaking change at this point... but it's a bit nasty to require something that isn't used. Make a PR and let's merge it quickly 😅. |
+1 if we do it quickly I think I'm okay breaking |
@johanbrandhorst It looks like @hb-chen's second PR got merged, so is this issue now officially closed? |
Did you mean another issue? This is a pull request, and it is merged already. |
sometimes we don't need the HTTP gateway to be a RPC.
just convert the gRPC service to an HTTP service.
this reduces one remote call.
example code