pull/455/head
wenxu12345 3 years ago committed by Xinwei Xiong(cubxxw-openim)
parent e7c5e465d1
commit 3debc27227

@ -44,19 +44,19 @@ func NewResolver(schema, etcdAddr, serviceName string) (*Resolver, error) {
r.schema = schema r.schema = schema
r.etcdAddr = etcdAddr r.etcdAddr = etcdAddr
resolver.Register(&r) resolver.Register(&r)
//
ctx, _ := context.WithTimeout(context.Background(), time.Second*5) //ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
conn, err := grpc.DialContext(ctx, GetPrefix(schema, serviceName), //conn, err := grpc.DialContext(ctx, GetPrefix(schema, serviceName),
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)), // grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)),
grpc.WithInsecure()) // grpc.WithInsecure())
log.Debug("", "etcd key ", GetPrefix(schema, serviceName), "value ", *r.grpcClientConn) log.Debug("", "etcd key ", GetPrefix(schema, serviceName), "value ", *r.grpcClientConn)
//conn, err := grpc.Dial( conn, err := grpc.Dial(
// GetPrefix(schema, serviceName), GetPrefix(schema, serviceName),
// grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)),
// grpc.WithInsecure(), grpc.WithInsecure(),
// grpc.WithTimeout(time.Duration(5)*time.Second), grpc.WithTimeout(time.Duration(5)*time.Second),
//) )
if err == nil { if err == nil {
r.grpcClientConn = conn r.grpcClientConn = conn
} }

Loading…
Cancel
Save