tianxiaoliang commented on a change in pull request #1205:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1205#discussion_r780087991



##########
File path: client/set.go
##########
@@ -19,13 +28,35 @@ type Set struct {
 }
 
 // NewSetForConfig dial grpc connection and create all grpc clients
-func NewSetForConfig(c SetConfig) (*Set, error) {
-       conn, err := grpc.Dial(c.Addr, grpc.WithInsecure())
+func NewSetForConfig(c SetConfig) (*grpc.ClientConn, *Set, error) {
+       if len(c.Addr) <= 0 {
+               return nil, nil, ErrAddrEmpty
+       }
+
+       var conn *grpc.ClientConn
+       var err error
+
+       if len(c.Addr) <= 1 {
+               conn, err = grpc.Dial(c.Addr[0], grpc.WithInsecure())
+       } else {
+               addr := make([]resolver.Address, 0, len(c.Addr))
+               for _, a := range c.Addr {
+                       addr = append(addr, resolver.Address{Addr: a})
+               }
+               r := manual.NewBuilderWithScheme(c.Scheme)
+               r.InitialState(resolver.State{Addresses: addr})
+               conn, err = grpc.Dial(r.Scheme()+":///", grpc.WithInsecure(), 
grpc.WithResolvers(r))

Review comment:
       为什么有3个/  给下标准的依据




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to