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

documentation: add stream lifecycle doc to NewStream #2060

Merged
merged 4 commits into from
May 11, 2018

Conversation

jeanbza
Copy link
Member

@jeanbza jeanbza commented May 10, 2018

This adds documentation around how to properly close a stream, and how ctx is used by streams.

@jeanbza
Copy link
Member Author

jeanbza commented May 10, 2018

(very unfamiliar with proto-gen-go) I'm looking at pubsub.pb.go, one of our autogenerated clients. I assume this is generated with proto-gen-go. It does not appear to have any method-level comments. @dfawley wrt documenting ctx usage, did you have in mind putting some method-level comments on these generated files, or?

@jeanbza jeanbza requested a review from dfawley May 10, 2018 19:09
@@ -101,7 +101,7 @@ type ClientStream interface {
}

// NewStream creates a new Stream for the client side. This is typically
// called by generated code.
// called by generated code. ctx is used for the lifetime of the stream.
Copy link
Member

Choose a reason for hiding this comment

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

If you're making changes here, would you mind summarizing what I wrote in #1854 regarding how to ensure a stream doesn't leak a goroutine? Something like:

// To ensure resources are not leaked due to the stream returned, one of the following
// actions must be performed:
//
// 1. call Close on the ClientConn,
// 2. cancel the context provided,
// 3. call RecvMsg until a non-nil error is returned, or
// 4. receive a non-nil error from Header or SendMsg besides io.EOF.
//
// If none of the above happen, a goroutine and a context will be leaked, and grpc
// will not call the optionally-configured stats handler with a stats.End message.

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

stream.go Outdated
@@ -114,7 +114,7 @@ func (cc *ClientConn) NewStream(ctx context.Context, desc *StreamDesc, method st
}

// NewClientStream creates a new Stream for the client side. This is typically
Copy link
Member

Choose a reason for hiding this comment

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

How about

// NewClientStream is a wrapper for ClientConn.NewStream.
//
// DEPRECATED: ....

to avoid the need to duplicate documentation.

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

@dfawley dfawley merged commit b75baa1 into grpc:master May 11, 2018
@jeanbza jeanbza deleted the doc_stream branch May 11, 2018 16:24
@menghanl menghanl changed the title small documentation addition to NewStream documentation: add stream lifecycle doc to NewStream May 17, 2018
@menghanl menghanl added the Type: Documentation Documentation or examples label May 17, 2018
@menghanl menghanl added this to the 1.13 Release milestone May 17, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Nov 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Documentation Documentation or examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants