From 41d94e2f407518654574daa921064a1f1531dcd7 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Fri, 29 Apr 2022 16:33:01 +0800 Subject: [PATCH] config --- pkg/grpc-etcdv3/getcdv3/resolver.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/grpc-etcdv3/getcdv3/resolver.go b/pkg/grpc-etcdv3/getcdv3/resolver.go index ea6367008..108266150 100644 --- a/pkg/grpc-etcdv3/getcdv3/resolver.go +++ b/pkg/grpc-etcdv3/getcdv3/resolver.go @@ -44,12 +44,16 @@ func NewResolver(schema, etcdAddr, serviceName string) (*Resolver, error) { r.etcdAddr = etcdAddr resolver.Register(&r) - conn, err := grpc.Dial( - GetPrefix(schema, serviceName), + ctx, _ := context.WithTimeout(context.TODO(), time.Second*5) + conn, err := grpc.DialContext(ctx, GetPrefix(schema, serviceName), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)), - grpc.WithInsecure(), - grpc.WithTimeout(time.Duration(5)*time.Second), - ) + grpc.WithInsecure()) + //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 }