Skip to content

Commit f64a76a

Browse files
committed
Merge branch 'fix/rpc-client' into 'main' (merge request !48)
fix: rpc client target
2 parents 07b1eff + ee0bd28 commit f64a76a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tcvectordb/rpc_client.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package tcvectordb
33
import (
44
"context"
55
"fmt"
6+
"log"
7+
"strings"
8+
"time"
9+
610
"github.com/pkg/errors"
711
"github.com/tencent/vectordatabase-sdk-go/tcvectordb/olama"
812
"google.golang.org/grpc"
913
"google.golang.org/grpc/credentials/insecure"
1014
"google.golang.org/grpc/metadata"
11-
"log"
12-
"strings"
13-
"time"
1415
)
1516

1617
type RpcClient struct {
@@ -37,6 +38,12 @@ func NewRpcClient(url, username, key string, option *ClientOption) (*RpcClient,
3738
if strings.HasPrefix(url, "http://") {
3839
httpTarget = url
3940
rpcTarget = strings.TrimPrefix(url, "http://")
41+
portIndex := strings.Index(rpcTarget, ":")
42+
if portIndex == -1 {
43+
rpcTarget += ":80"
44+
}
45+
} else if strings.HasPrefix(url, "https://") {
46+
return nil, errors.Errorf("invalid url param with %v for not supporting https://", url)
4047
} else {
4148
httpTarget = "http://" + url
4249
rpcTarget = url

0 commit comments

Comments
 (0)