Skip to content

Commit

Permalink
feat: add a method to get gRPC connection from the client
Browse files Browse the repository at this point in the history
This change is for Theila which is going to use gRPC proxy to forward
requests from TS frontend right to the node's apid.
`gRPC` proxy operates on top of `grpc.ClientConn` objects, so getting
this connection from the clients which are already being created is the
easiest path.

Signed-off-by: Artem Chernyshev <[email protected]>
  • Loading branch information
Unix4ever authored and smira committed Jun 24, 2021
1 parent b5244bf commit 7672435
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/machinery/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func New(ctx context.Context, opts ...OptionFunc) (c *Client, err error) {
return nil, errors.New("failed to determine endpoints")
}

c.conn, err = c.getConn(ctx)
c.conn, err = c.GetConn(ctx)
if err != nil {
return nil, fmt.Errorf("failed to create client connection: %w", err)
}
Expand All @@ -166,7 +166,8 @@ func New(ctx context.Context, opts ...OptionFunc) (c *Client, err error) {
return c, nil
}

func (c *Client) getConn(ctx context.Context, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
// GetConn creates new gRPC connection.
func (c *Client) GetConn(ctx context.Context, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
endpoints := c.getEndpoints()

var target string
Expand Down

0 comments on commit 7672435

Please sign in to comment.