[#301] api: Call dialer for open connections too
All checks were successful
DCO / DCO (pull_request) Successful in 3m27s
Tests and linters / Tests (pull_request) Successful in 3m43s
Tests and linters / Lint (pull_request) Successful in 4m19s

* 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:
Airat Arifullin 2024-12-04 15:17:43 +03:00
parent cb813e27a8
commit e295f3afa5

View file

@ -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 {