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
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

func (cc *ClientConn) NewStream(ctx context.Context, desc *StreamDesc, method string, opts ...CallOption) (ClientStream, error) {
// allow interceptor to see all applicable call options, which means those
// configured as defaults from dial option as well as per-call options
Expand All @@ -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

// called by generated code.
// called by generated code. ctx is used for the lifetime of the stream.
//
// DEPRECATED: Use ClientConn.NewStream instead.
func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) {
Expand Down