Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
fix: fix input address format mistake (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuLiangWang authored Oct 27, 2022
1 parent 2812927 commit dbe6022
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion server/service/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package service

import (
"context"
"net/url"
"strings"

"github.com/CeresDB/ceresmeta/pkg/coderr"
"google.golang.org/grpc"
Expand All @@ -19,7 +21,16 @@ var (
func GetClientConn(ctx context.Context, addr string) (*grpc.ClientConn, error) {
opt := grpc.WithTransportCredentials(insecure.NewCredentials())

cc, err := grpc.DialContext(ctx, addr, opt)
host := addr
if strings.HasPrefix(addr, "http") {
u, err := url.Parse(addr)
if err != nil {
return nil, ErrParseURL.WithCause(err)
}
host = u.Host
}

cc, err := grpc.DialContext(ctx, host, opt)
if err != nil {
return nil, ErrGRPCDial.WithCause(err)
}
Expand Down

0 comments on commit dbe6022

Please sign in to comment.