From 34f42d679e462713100f6e32270424822f47de10 Mon Sep 17 00:00:00 2001 From: lc-1010 <532398960@qq.com> Date: Mon, 24 Jul 2023 23:35:21 +0800 Subject: [PATCH] chore: Update client #16 --- client/client.go | 14 ++------------ cmd/gateway/main.go | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/client/client.go b/client/client.go index fc489a4..3145e63 100644 --- a/client/client.go +++ b/client/client.go @@ -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 } @@ -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)) @@ -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 { diff --git a/cmd/gateway/main.go b/cmd/gateway/main.go index 29e66cc..bb6c6fd 100644 --- a/cmd/gateway/main.go +++ b/cmd/gateway/main.go @@ -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)