-
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
allow storing alternate transport.ServerStream implementations in context #1904
Conversation
…text -- for tests and for implementing alternate transports
Ping? |
A couple observations/quesitons:
|
In it's current form, it does -- the mechanism for storing a transport stream into context. But I think I can move stuff around so that is not the case (so that new exported API is in the main
I suppose it depends. If, in the process of creating an alternate transport, the gRPC library gained better abstractions that de-couple the interfaces from the existing singular implementations, then maybe! But if there were no additional abstractions provided for custom transports, then that would only help so much. We also want this for an HTTP 1.1 transport implementation. And, generally, abstracting these details so that custom transports can be used is IMO very empowering to users. Another argument for something like this is to resolve #1494, to make the interceptor model generally more coherent. As is, only streaming interceptors can actually intercept response metadata (both client and server sides). But this change makes it possible for a unary interceptor to do so -- by installing its own "transport stream" implementation in context that can intercept metadata and forward to the real stream. (Similarly, #1902 enables intercepting metadata for unary RPCs on the client side.) |
I pushed a change so that new API is in the main @dfawley: Does this seem better? |
ping |
…ream (and corresponding interface); move to grpc package (out of transport package)
41aaea6
to
eff3003
Compare
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.
Thank you @dfawley! I understand that it is not ideal. I do appreciate you merging it anyway. |
For anyone stumbling here, this commit perfectly describes how to fix For example, I had this problem with https://github.com/improbable-eng/grpc-web, and the following worked: go get -u github.com/improbable-eng/grpc-web/go/grpcwebproxy
cd $GOPATH/src/github.com/improbable-eng/grpc-web
brew install dep # install golang/dep somehow
dep ensure
go get -u github.com/improbable-eng/grpc-web/go/grpcwebproxy After that |
Fixes #1802.
This allows handlers to be run from tests without requiring the entirety of the gRPC server machinery: a test can store a mock
transport.ServerStream
into the context and then call the handler.It also enables alternate transport implementations.