Skip to content

Commit

Permalink
[#419] rpc/client: Block until client connection is up
Browse files Browse the repository at this point in the history
In previous implementation `Client` didn't block until the connection is
up on dial stage. This caused the dial timeout to have no effect.

Provide `WithBlock` dial option to `DialContext` call in `openGRPCConn`
method. From now `Client` blocks for configured timeout until the
connection is up.

Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
  • Loading branch information
Leonard Lyubich authored and cthulhu-rider committed Oct 5, 2022
1 parent 5fc2644 commit 2b89b7e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rpc/client/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ func (c *Client) openGRPCConn() error {

dialCtx, cancel := context.WithTimeout(context.Background(), c.dialTimeout)
var err error
c.conn, err = grpcstd.DialContext(dialCtx, c.addr, grpcstd.WithTransportCredentials(creds))
c.conn, err = grpcstd.DialContext(dialCtx, c.addr,
grpcstd.WithTransportCredentials(creds),
grpcstd.WithBlock(),
)
cancel()
if err != nil {
return fmt.Errorf("open gRPC client connection: %w", err)
}

return err
return nil
}

// ParseURI parses s as address and returns a host and a flag
Expand Down

0 comments on commit 2b89b7e

Please sign in to comment.