Skip to content

Commit

Permalink
feat(transport/bytestream): Add Close method for shutdown
Browse files Browse the repository at this point in the history
This pacakge is still labeled expirmental. At some point we should
decide if we want to keep supporting it or deprecate and remove.

Fixes: googleapis#775
  • Loading branch information
codyoss committed Dec 11, 2020
1 parent b4a3262 commit e4efe16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions transport/bytestream/client.go
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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()
}
2 changes: 1 addition & 1 deletion transport/bytestream/client_test.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -425,5 +424,6 @@ func newTestSetup(input string) *TestSetup {
}

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

0 comments on commit e4efe16

Please sign in to comment.