-
Notifications
You must be signed in to change notification settings - Fork 103
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
gRPC transport initial work with crossdock testing #863
Conversation
Just for the record, I don't agree with a couple of the filed
issues/proposed solutions, and I think a couple of them are bigger than
just gRPC (ie they really apply to all transports, and are larger cleanup
tasks across the transport package), but we can discuss heh :)
…On Tue, Apr 11, 2017 at 2:39 AM Kris Kowal ***@***.***> wrote:
@peter-edge <https://github.com/peter-edge> @willhug
<https://github.com/willhug> For proxies, I imagine we’ll have to support
an HTTP/2 shunt or bypass. We have a proxy in production that does this for
HTTP REST services and this will likely be more of the same. We will need
to explore first class support #910
<#910>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#863 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AECGvN4yV9TcQs0otwEU919_d8zLodhAks5rusvHgaJpZM4MuhcK>
.
|
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.
Alright, I've gone through pretty deep on most of the code. For now I'm going to request changes, but I'll take another look tomorrow morning and approve after that.
Note I've made a few comments about linking "TODOs" to tasks/issues where we can follow-up. This will give people who stumble upon these TODOs a place to look for follow-ups/issues with the TODOs.
transport/x/grpc/handlers.go
Outdated
if err := request.ValidateUnaryContext(ctx); err != nil { | ||
return nil, err | ||
} | ||
protobuf.SetRawResponse(transportRequest.Headers) |
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.
we seem to have pretty tight coupling between the GRPC transport and the Protobuf encoding. Is it possible for us to avoid this? It reduces the flexibility of both the transport and the encoding.
transport/x/grpc/codec.go
Outdated
|
||
func (customCodec) String() string { | ||
// TODO: faking this as proto to be compatible with existing grpc clients | ||
return "proto" |
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.
for this todo, can we link to this task: #911
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.
done
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
// Package grpc implements the grpc transport. |
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.
We should elaborate here a bit more about how the structure, how this is experimental, and should not be used (yet).
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've added a comment about the experimental status, but note that existing x/ packages are inconsistent on this topic. This comment I know is a nit, but in the spirit of tracking issues, I've added #918 to track this
transport/x/grpc/handler.go
Outdated
) | ||
|
||
type handler struct { | ||
procedureServiceName string |
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.
maybe we should prefix these with their "origin"
yarpcServiceName
grpcServiceName
grpcMethodName
I'm keep having to remind myself the difference between the three strings.
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.
done
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.
done
transport/x/grpc/handler.go
Outdated
} | ||
} | ||
|
||
func (h *handler) handle( |
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.
can we add a comment about how the GRPC handler does not put context first, and therefore has invalid lint?
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.
done
// CreateTransport creates an RPC from the given parameters or fails the whole behavior. | ||
// | ||
// If trans is non-empty, this will be used instead of the behavior transport. | ||
func CreateTransport(t crossdock.T, trans string) *yarpc.Dispatcher { |
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.
CreateDispatcherForTransport?
Transport is already a top-level object, so it's a bit confusing that a "CreateTransport" function returns a dispatcher.
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.
Ya for sure, updated
// useGrpc checks to see if a grpc server is expected to be | ||
// available | ||
func useGrpc() bool { | ||
return os.Getenv("GRPC") == "enabled" |
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.
is this envVar limited to just the oneway tests? And, if so, should we make the envVar more explicit? (Additionally, I'm not sure how I feel about gating this test based on whether an environment variable is set, I could see some weird "i don't see the error" cases shrug)
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.
This is something I don't like either, but it's how the existing setup is. I agree with you, I think this could lead to misleading errors, and that we should fail if a transport is not able to come up, without having any conditionals in environment variables. I'm making a tracking issue for this as a cleanup task #916.
@@ -45,13 +48,18 @@ func Start() { | |||
if err != nil { | |||
log.Panicf("failed to build ChannelTransport: %v", err) | |||
} | |||
grpcListener, err := net.Listen("tcp", ":8089") |
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.
can we share tcp connections in grpc? If not, should we be exposing it?
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.
@@ -102,6 +104,12 @@ func do() error { | |||
return err | |||
} | |||
inbound = tchannelTransport.NewInbound() | |||
case "grpc": | |||
listener, err := net.Listen("tcp", "127.0.0.1:24038") |
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.
do we need the 127.0.0.1
? Not blocking, just curious
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.
This is a recommendation that Prashant had previously. I don't actually think it makes a difference, but I'm trying to do it for new connections I make.
@@ -159,6 +159,16 @@ type Service struct { | |||
Methods []*Method | |||
} | |||
|
|||
// FQSN returns a fully qualified service name of this service. |
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.
can we add that to the comment here? Just for clarity in the code when someone else comes along.
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.
whoops, requesting changes
I've responded to all comments, and I've tried to make sure I have linked to current discussions and/or issues where I should, I hope this helps |
caller, callerErr := getFromMetadata(md, callerHeader) | ||
request.Caller = caller | ||
encoding, encodingErr := getFromMetadata(md, encodingHeader) | ||
request.Encoding = transport.Encoding(encoding) |
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.
does this cast work if the encoding is null/empty?
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.
Yea, the cast is fine regardless
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.
return o.tracer | ||
} | ||
|
||
func defaultOnewayErrorHandler(err error) { |
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.
shrug emoji
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.
This is really exciting.
We'll want to follow up with Crossdock tests that verify:
- a gRPC client can call a YARPC server
- a YARPC client can call a gRPC server
docker-compose.yml
Outdated
environment: | ||
- REDIS=enabled | ||
- CHERAMI=enabled | ||
- GRPC=enabled |
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 understand why Redis and Cherami need to be toggleable, but why GRPC?
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 was just following the pattern, I will remove, also note #916
@@ -10,6 +10,10 @@ import: | |||
version: ~0.4 | |||
- package: github.com/golang/mock | |||
version: master | |||
- package: github.com/grpc-ecosystem/grpc-opentracing | |||
version: master |
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.
No semver here?
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.
grpc-opentracing isn't doing releases unfortunately :( we need to evaluate grpc-opentracing more anyways before grpc can get out of the x/ package
} | ||
|
||
// ProtobufTransport implements the 'protobuf' behavior for the given transport or behavior transport. | ||
func ProtobufTransport(t crossdock.T, transport string) { |
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.
Not wild about the naming of this func... think you can introduce a verb in here?
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.
Changed to ProtobufForTransport
, also updated this for json/raw/thrift
@breerly ya I want to add those crossdock tests as well, also in one other non-common language if possible, filed #934 |
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.
Great start - it's exciting to start iterating from here with the goal of getting gRPC and protobuf out of x/ and into peoples hands.
Done so far:
To do:
peer.Chooser
etcGenerally I want to get most of this in, and then iterate from there. This is a start, we can refine as we go, I want to get the basics committed to x/ and then I can add stuff with more granularity.