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

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

Merged
merged 2 commits into from Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()
}