-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Document Server.ServeHTTP #1406
Conversation
/cc @dfawley |
I don’t find this documentation actually any more clear. I think more harnessing of the example might be important. Where is this code snippet supposed to go? How am I supposed to get yourMux? etc. It still seems like the code is written towards people who already know how the functionality works, and doesn’t need all the “magic” spelled out for them. |
The yourMux is just another http.Handler, so whatever would handle your non grpc requests. You might create it from http.NewServeMux() or any of the various http router packages that are available. You'd probably have this snippet inside some kind of request director ServeHTTP() or http.HandlerFunc middleware. |
I don’t think putting said explanation here or in a FAQ would be documenting the code clearly. |
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.
Thanks, this is helpful. Could we add a disclaimer to this docstring, as well? Something like:
This functionality is experimental and unsupported. Serving gRPC
through another HTTP server prevents some gRPC features from
working, and may impact performance significantly.
I think the docstring here is sufficient to at least point users toward the http package so they can figure out the rest. If more help is necessary, a user manual or examples would be more appropriate IMO. Although, TBH, with the downsides of this method of serving, I would like to discourage its use by all but the biggest power users that already know how this stuff works. #549 did specifically mention adding usage examples. @bradfitz, do you still have the examples referenced in #549?:
Thanks! |
I would prefer it as-is without the FUD. The words "may" and "significantly" in your proposed addition are at opposite sides of the certainly spectrum. If you want to cite actual features they'll lose, that's fine. But which? |
I don't see these as opposites. "May" describes certainty, while "significantly" describes severity.
Keepalive, keepalive enforcement (ping flood prevention), max connection age and idleness detection, flow control settings and optimizations (e.g. BDP estimation and large message optimizations), stream-level flow control tied to application reads, GracefulStop(), InTapHandle(), stats hooks, status details, and possibly others. I'd rather keep the FUD levels high here until such time that this path is well-understood and well-supported by the maintainers, which is currently not the case. |
What is "keepalive"? Go's HTTP/2 server keeps connections alive too, by default. We also have idle timeouts (https://tip.golang.org/pkg/net/http/#Server ... https://tip.golang.org/pkg/net/http/#Server.IdleTimeout) We don't do BDP estimation, that's true. If you want a caveat, I'd prefer a caveat emptor wording that says it's a different HTTP/2 server implementation and "performance and available features may vary", without saying ServeHTTP "may" only suck more. I'd argue in a number of ways that Go's http2 server is more solid. |
I've pushed an addition with a possible caveat paragraph: |
I like the documentation a lot more now. 👍 |
Settings in gRPC to control pings to check liveness (ref), and matching server enforcement rules. Even if the http2 package supports idle timeouts, we aren't configuring them right now in gRPC. And AIUI, we (within gRPC) can't if we're going through the ServeHTTP method of serving, because we don't have access to the server itself with this mechanism -- unless we hijack the net.Conn away from the server?
I'm not making any value judgments. But for now, the team is working almost exclusively on the gRPC transport, not the http2 one. We've repeatedly heard that performance is a problem with gRPC through a handler, but we haven't had time to look into this, nor do I expect we will in the next quarter or two. So for now I'd rather lead people (strongly) toward using our server. If our server 1 year from now just fires up x/net/http2, then that would be great, but that is not the current state of things. I'm OK with the text of the paragraph that is there, but I would like to add a sentence to let people know it is not ("well"?) supported right now. |
@bradfitz asked me to finish this off, as he won't have enough cycles to do so personally. I'll submit it and add the extra sentence I was requesting. Thanks for the PR. |
Fixes #549