pull/455/head
wenxu12345 3 years ago committed by Xinwei Xiong(cubxxw-openim)
parent d88036758b
commit 7c3b3431fe

@ -45,18 +45,18 @@ func NewResolver(schema, etcdAddr, serviceName string) (*Resolver, error) {
r.etcdAddr = etcdAddr
resolver.Register(&r)
//
//ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
//conn, err := grpc.DialContext(ctx, GetPrefix(schema, serviceName),
// grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)),
// grpc.WithInsecure())
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
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))
conn, err := grpc.Dial(
GetPrefix(schema, serviceName),
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)),
grpc.WithInsecure(),
grpc.WithTimeout(time.Duration(5)*time.Second),
)
//conn, err := grpc.Dial(
// GetPrefix(schema, serviceName),
// grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)),
// grpc.WithInsecure(),
// grpc.WithTimeout(time.Duration(5)*time.Second),
//)
if err == nil {
r.grpcClientConn = conn
}
@ -104,7 +104,7 @@ func (r *Resolver) Build(target resolver.Target, cc resolver.ClientConn, opts re
return nil, fmt.Errorf("etcd clientv3 client failed, etcd:%s", target)
}
r.cc = cc
log.Debug("", "Build..")
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
// "%s:///%s"
prefix := GetPrefix(r.schema, r.serviceName)

Loading…
Cancel
Save