Skip to content
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 proper support for 'identity' encoding type #1664

Merged
merged 3 commits into from
Nov 17, 2017
Merged

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Nov 10, 2017

I also added a document to explain how this is supposed to work, and how it works if you use the legacy compressor/decompressor.

Fixes #1654

@tsuna
Copy link
Contributor

tsuna commented Nov 10, 2017

Just to be sure: did you verify that a Python client can now talk to a Go server with this change?

@dfawley
Copy link
Member Author

dfawley commented Nov 10, 2017

@tsuna, I did not specifically test this using a Python client, but I added a test case that sets "identity" in the grpc-encoding header and makes sure the server behaves correctly.

Would you be able to patch this change into your environment and test it?

@tsuna
Copy link
Contributor

tsuna commented Nov 10, 2017

I can try it but it's not the first time we run into this sort of interop issue, it would be nice if upstream did better testing of interop between the various implementations of gRPC.

@dfawley
Copy link
Member Author

dfawley commented Nov 10, 2017

We have interop tests, both in open source and inside Google, and I am following-up to figure out why they didn't catch this issue.

[`WithDefaultCallOptions`](https://godoc.org/google.golang.org/grpc#WithDefaultCallOptions)
`DialOption`.

Server-side, registered compressors will be used automatically to decode request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also mention what happens if the request compressor is not registered?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, and added the same thing above in the case that UseCompressor specifies an unregistered compressor. (I left out the details about "identity", because I don't think it's worth mentioning, and it's covered in the bottom section.)

call.go Outdated
// otherwise set comp if a registered compressor exists for it.
var comp encoding.Compressor
var dc Decompressor
if rc := stream.RecvCompress(); dopts.dc == nil || dopts.dc.Type() != rc {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reorder if and else?

if rc := stream.RecvCompress(); dopts.dc != nil && dopts.dc.Type() == rc {
    dc = dopts.dc
} else if rc != "" && rc != encoding.Identity {
    comp = encoding.GetCompressor(rc)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (x3)

server.go Outdated

// If dc is set and matches the stream's compression, use it. Otherwise, try
// to find a matching registered compressor for decomp.
if rc := stream.RecvCompress(); s.opts.dc == nil || s.opts.dc.Type() != rc {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reorder if and else?

if rc := stream.RecvCompress(); s.opts.dc != nil && s.opts.dc.Type() == rc {
    dc = s.opts.dc
} else if rc != "" && rc != encoding.Identity {
    decomp = encoding.GetCompressor(rc)
}

Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Some nits.

stream.go Outdated
@@ -637,6 +666,7 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) {
}

func (ss *serverStream) RecvMsg(m interface{}) (err error) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this?

vet.sh Outdated
@@ -76,5 +76,5 @@ if [[ "$check_proto" = "true" ]]; then
fi

# TODO(menghanl): fix errors in transport_test.
staticcheck -ignore google.golang.org/grpc/transport/transport_test.go:SA2002 ./...
staticcheck -ignore "google.golang.org/grpc/transport/transport_test.go:SA2002 google.golang.org/grpc/benchmark/benchmain/main.go:SA1019 google.golang.org/grpc/stats/stats_test.go:SA1019 google.golang.org/grpc/test/end2end_test.go:SA1019" ./...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this: create a file staticcheck.ignore, and do

staticcheck -ignore "$(cat staticcheck.ignore)" ./...

@dfawley dfawley merged commit 816fa5b into grpc:master Nov 17, 2017
@dfawley dfawley deleted the identity branch November 17, 2017 17:26
@menghanl menghanl added this to the 1.8 Release milestone Nov 20, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants