Skip to content

Commit

Permalink
Merge pull request #719 from erikreppel/close-client-connection
Browse files Browse the repository at this point in the history
Add gRPC conn as prop of the ApiClient struct so it can be closed at a later time
  • Loading branch information
jdoliner committed Aug 15, 2016
2 parents e478bb9 + 6bd2712 commit 7dca5a5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type APIClient struct {
PfsAPIClient
PpsAPIClient
BlockAPIClient
gRPCConn *grpc.ClientConn
}

// NewFromAddress constructs a new APIClient for the server at pachAddr.
Expand All @@ -42,6 +43,7 @@ func NewFromAddress(pachAddr string) (*APIClient, error) {
pfs.NewAPIClient(clientConn),
pps.NewAPIClient(clientConn),
pfs.NewBlockAPIClient(clientConn),
clientConn,
}, nil
}

Expand All @@ -58,6 +60,11 @@ func NewInCluster() (*APIClient, error) {
return NewFromAddress(fmt.Sprintf("%v:650", pachAddr))
}

// Close the connection to gRPC
func (c *APIClient) Close() error {
return c.gRPCConn.Close()
}

// DeleteAll deletes everything in the cluster.
// Use with caution, there is no undo.
func (c APIClient) DeleteAll() error {
Expand Down

0 comments on commit 7dca5a5

Please sign in to comment.