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

Get method string from stream #1588

Merged
merged 8 commits into from
Oct 26, 2017
Merged

Get method string from stream #1588

merged 8 commits into from
Oct 26, 2017

Conversation

lyuxuan
Copy link
Contributor

@lyuxuan lyuxuan commented Oct 17, 2017

fix #1549

@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
The Linux Foundation CLA GitHub bot

@lyuxuan
Copy link
Contributor Author

lyuxuan commented Oct 17, 2017

I signed it.

stream.go Outdated
@@ -655,3 +655,12 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) {
}
return nil
}

// GetMethodFromStream returns the method string that the input stream is used for.
Copy link
Contributor

Choose a reason for hiding this comment

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

The returned string is in the format of "/service/method".

@lyuxuan
Copy link
Contributor Author

lyuxuan commented Oct 21, 2017

fix #1549

defer te.tearDown()
_ = te.clientConn().Invoke(context.Background(), "foo/bar", nil, nil)
if !ok || method != "foo/bar" {
t.Fatalf("Invoke with method \"foo/bar\", got %s, %v, want \"foo/bar\", true", method, ok)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: define a testing const, and print %q to avoid escaping "s.

const testMethod = "/package.service/method"

if !ok || method != testMethod {
		t.Fatalf("Invoke with method %q, got %q, %v, want %q, true", testMethod, method, ok, testMethod)
}

@lyuxuan lyuxuan merged commit a4ff4e2 into grpc:master Oct 26, 2017
@menghanl menghanl added this to the 1.8 Release milestone Nov 7, 2017
@menghanl menghanl added the Type: Feature New features or improvements in behavior label Nov 7, 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.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Method and service names not provided to UnknownServiceHandlers
3 participants