Skip to content
Permalink
Browse files

feat(transport/bytestream): Add Close method for shutdown (#787)

This pacakge is still labeled expirmental. At some point we should
decide if we want to keep supporting it or deprecate and remove.

Fixes: #775
  • Loading branch information
codyoss committed Jan 11, 2021
1 parent b684ed8 commit 96bfd877fbc5869c0a4d87de4daeb1f76aaca79d
Showing with 9 additions and 1 deletion.
  1. +8 −0 transport/bytestream/client.go
  2. +1 −1 transport/bytestream/client_test.go
@@ -33,13 +33,15 @@ const (
type Client struct {
client pb.ByteStreamClient
options []grpc.CallOption
conn *grpc.ClientConn
}

// NewClient creates a new bytestream.Client.
func NewClient(cc *grpc.ClientConn, options ...grpc.CallOption) *Client {
return &Client{
client: pb.NewByteStreamClient(cc),
options: options,
conn: cc,
}
}

@@ -228,3 +230,9 @@ func (c *Client) NewWriter(ctx context.Context, resourceName string) (*Writer, e
resourceName: resourceName,
}, nil
}

// Close closes the connection to the API service. The user should invoke this when
// the client is no longer required.
func (c *Client) Close() {
c.conn.Close()
}
@@ -307,7 +307,6 @@ func TestClientWrite_WriteFails(t *testing.T) {
}

func TestClientWrite_CloseAndRecvFails(t *testing.T) {
t.Skip("https://github.com/googleapis/google-api-go-client/issues/775")
setup := newTestSetup("")
w, err := setup.client.NewWriter(setup.ctx, "CloseAndRecvFails")
if err != nil {
@@ -425,5 +424,6 @@ func newTestSetup(input string) *TestSetup {
}

func (testSetup *TestSetup) Close() {
testSetup.client.Close()
testSetup.rpcTest.Close()
}

0 comments on commit 96bfd87

Please sign in to comment.