Skip to content

Commit

Permalink
fix grpc dialer
Browse files Browse the repository at this point in the history
  • Loading branch information
ginuerzh committed Mar 7, 2023
1 parent 7a21c7e commit f32b72c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions dialer/grpc/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ func (d *grpcDialer) Multiplex() bool {
}

func (d *grpcDialer) Dial(ctx context.Context, addr string, opts ...dialer.DialOption) (net.Conn, error) {
/*
remoteAddr, err := net.ResolveTCPAddr("tcp", addr)
if err != nil {
return nil, err
}
*/

d.clientMutex.Lock()
defer d.clientMutex.Unlock()

Expand All @@ -66,9 +59,13 @@ func (d *grpcDialer) Dial(ctx context.Context, addr string, opts ...dialer.DialO
opt(&options)
}

adr := addr
if h, p, err := net.SplitHostPort(addr); err == nil && h == "" {
adr = net.JoinHostPort("localhost", p)
}
host := d.md.host
if host == "" {
host = options.Host
host = adr
}
if h, _, _ := net.SplitHostPort(host); h != "" {
host = h
Expand Down Expand Up @@ -100,7 +97,7 @@ func (d *grpcDialer) Dial(ctx context.Context, addr string, opts ...dialer.DialO
}))
}

cc, err := grpc.DialContext(ctx, addr, grpcOpts...)
cc, err := grpc.DialContext(ctx, adr, grpcOpts...)
if err != nil {
d.options.Logger.Error(err)
return nil, err
Expand Down

0 comments on commit f32b72c

Please sign in to comment.