Skip to content

Commit

Permalink
small documentation addition to NewStream (#2060)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanbza authored and dfawley committed May 11, 2018
1 parent 0ebfac4 commit b75baa1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,18 @@ 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.
//
// 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, non-io.EOF error from Header or SendMsg.
//
// 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.
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 @@ -113,8 +124,7 @@ func (cc *ClientConn) NewStream(ctx context.Context, desc *StreamDesc, method st
return newClientStream(ctx, desc, cc, method, opts...)
}

// NewClientStream creates a new Stream for the client side. This is typically
// called by generated code.
// NewClientStream is a wrapper for ClientConn.NewStream.
//
// DEPRECATED: Use ClientConn.NewStream instead.
func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) {
Expand Down

0 comments on commit b75baa1

Please sign in to comment.