[#301] api: Call dialer
for open connections too
* If a client instance already sets `conn`, then `dialer` should be called for this `conn` anyway. `conn` may turn to invalidated state and thus we can check it with `dialer`. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
cb813e27a8
commit
e295f3afa5
1 changed files with 9 additions and 11 deletions
|
@ -13,19 +13,17 @@ import (
|
|||
var errInvalidEndpoint = errors.New("invalid endpoint options")
|
||||
|
||||
func (c *Client) openGRPCConn(ctx context.Context, dialer func(ctx context.Context, cc grpcstd.ClientConnInterface) error) error {
|
||||
if c.conn != nil {
|
||||
return nil
|
||||
}
|
||||
if c.conn == nil {
|
||||
if c.addr == "" {
|
||||
return errInvalidEndpoint
|
||||
}
|
||||
|
||||
if c.addr == "" {
|
||||
return errInvalidEndpoint
|
||||
}
|
||||
var err error
|
||||
|
||||
var err error
|
||||
|
||||
c.conn, err = grpcstd.NewClient(c.addr, c.grpcDialOpts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("gRPC new client: %w", err)
|
||||
c.conn, err = grpcstd.NewClient(c.addr, c.grpcDialOpts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("gRPC new client: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if dialer != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue