From e1ee0500ea9bd27df498d29e13428b6f845181db Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Fri, 29 Apr 2022 16:42:42 +0800 Subject: [PATCH] config --- pkg/grpc-etcdv3/getcdv3/resolver.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/grpc-etcdv3/getcdv3/resolver.go b/pkg/grpc-etcdv3/getcdv3/resolver.go index 108266150..4a8c5d644 100644 --- a/pkg/grpc-etcdv3/getcdv3/resolver.go +++ b/pkg/grpc-etcdv3/getcdv3/resolver.go @@ -1,6 +1,7 @@ package getcdv3 import ( + "Open_IM/pkg/common/log" "context" "fmt" "strings" @@ -48,6 +49,8 @@ func NewResolver(schema, etcdAddr, serviceName string) (*Resolver, error) { conn, err := grpc.DialContext(ctx, GetPrefix(schema, serviceName), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)), grpc.WithInsecure()) + log.Debug("", "etcd key ", GetPrefix(schema, serviceName), "value ", *r.grpcClientConn) + //conn, err := grpc.Dial( // GetPrefix(schema, serviceName), // grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)), @@ -71,6 +74,7 @@ func GetConn(schema, etcdaddr, serviceName string) *grpc.ClientConn { r, ok := nameResolver[schema+serviceName] rwNameResolverMutex.RUnlock() if ok { + log.Debug("", "etcd key ", schema+serviceName, "value ", *r.grpcClientConn, *r) return r.grpcClientConn } @@ -78,15 +82,18 @@ func GetConn(schema, etcdaddr, serviceName string) *grpc.ClientConn { r, ok = nameResolver[schema+serviceName] if ok { rwNameResolverMutex.Unlock() + log.Debug("", "etcd key ", schema+serviceName, "value ", *r.grpcClientConn, *r) return r.grpcClientConn } r, err := NewResolver(schema, etcdaddr, serviceName) if err != nil { + log.Error("", "etcd failed ", schema, etcdaddr, serviceName) rwNameResolverMutex.Unlock() return nil } + log.Debug("", "etcd key ", schema+serviceName, "value ", *r.grpcClientConn, *r) nameResolver[schema+serviceName] = r rwNameResolverMutex.Unlock() return r.grpcClientConn