forked from TrueCloudLab/frostfs-api-go
[#419] rpc/client: Block until client connection is up
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>
This commit is contained in:
parent
5fc2644c68
commit
2b89b7e798
1 changed files with 8 additions and 2 deletions
|
@ -49,10 +49,16 @@ func (c *Client) openGRPCConn() error {
|
||||||
|
|
||||||
dialCtx, cancel := context.WithTimeout(context.Background(), c.dialTimeout)
|
dialCtx, cancel := context.WithTimeout(context.Background(), c.dialTimeout)
|
||||||
var err error
|
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()
|
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
|
// ParseURI parses s as address and returns a host and a flag
|
||||||
|
|
Loading…
Reference in a new issue