Skip to content

Commit

Permalink
chore: Update client
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-1010 committed Jul 24, 2023
1 parent 918b666 commit 34f42d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
14 changes: 2 additions & 12 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func GetClientConn(ctx context.Context, serviceName string, opts []grpc.DialOpti
DialTimeout: time.Second * 15,
}
cli, err := clientv3.New(config)
//cli, err := clientv3.NewFromURL("http://localhost:2379")
cli, err = clientv3.NewFromURL("http://localhost:2379")
if err != nil {
return nil, err
}
Expand All @@ -123,6 +123,7 @@ func GetClientConn(ctx context.Context, serviceName string, opts []grpc.DialOpti
}
log.Printf("etcdResolver:%#v\n", etcdResolver)
//target := fmt.Sprintf("%s:%d", "tag-service", 8004)

opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithResolvers(etcdResolver))

Expand All @@ -138,17 +139,6 @@ func GetClientConn(ctx context.Context, serviceName string, opts []grpc.DialOpti

}

func ff(cli *clientv3.Client) {
res, err := cli.Get(context.Background(), "/etcd://blogServer/grpc/tag-service/", clientv3.WithPrefix())
if err != nil {
log.Fatal(err)
}
for _, kv := range res.Kvs {
fmt.Printf("---->Key: %s, Value: %s\n", kv.Key, kv.Value)
}
fmt.Printf("res-->%#v", res)
}

func init() {
err := setupTracer()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func RunServerEtcd(port string) error {

defer etcdClient.Close()
logger, _ := zap.NewDevelopment(zap.AddCaller(), zap.AddStacktrace(zap.DebugLevel))
target := fmt.Sprintf("etcd:///blogServer/grpc/%s", SERVICE_NAME)
target := fmt.Sprintf("blogServer/grpc/%s", SERVICE_NAME)
fmt.Println(target, port)
grpcproxy.Register(logger, etcdClient, target, ":"+port, 60)

Expand Down

0 comments on commit 34f42d6

Please sign in to comment.