AlexStocks commented on a change in pull request #158:
URL: https://github.com/apache/dubbo-go-pixiu/pull/158#discussion_r619730024



##########
File path: pkg/config/config_load.go
##########
@@ -84,25 +84,53 @@ func YAMLConfigLoad(path string) *model.Bootstrap {
                log.Fatalln("[config] [yaml load] load config failed, ", err)
        }
        cfg := &model.Bootstrap{}
-
        bytes, err := yaml.YAMLToJSON(content)
        if err != nil {
                log.Fatalln("[config] [yaml load] convert YAML to JSON failed, 
", err)
        }
-
        err = json.Unmarshal(bytes, cfg)
        if err != nil {
                log.Fatalln("[config] [yaml load] yaml unmarshal config failed, 
", err)
        }
+       adapter(cfg)
+       return cfg
+}
 
-       // other adapter
+// DefaultConfigLoad if not config, will load this
+func DefaultConfigLoad(path string) *model.Bootstrap {
+       log.Println("load config from : ", path)

Review comment:
       log.debug?

##########
File path: pkg/config/config_load.go
##########
@@ -168,22 +185,22 @@ func YAMLConfigLoad(path string) *model.Bootstrap {
                }
                c.Lb = model.LbPolicy(lbPolicy)
        }
-
-       return cfg
 }
 
-// DefaultConfigLoad if not config, will load this
-func DefaultConfigLoad(path string) *model.Bootstrap {
-       log.Println("load config from : ", path)
-       content, err := ioutil.ReadFile(path)
-       if err != nil {
-               log.Fatalln("[config] [default load] load config failed, ", err)
-       }
-       cfg := &model.Bootstrap{}
-       // translate to lower case
-       err = json.Unmarshal(content, cfg)
-       if err != nil {
-               log.Fatalln("[config] [default load] json unmarshal config 
failed, ", err)
+func DiscoverType(cfg *model.Bootstrap) {
+       for _, c := range cfg.StaticResources.Clusters {
+               var discoverType int32

Review comment:
       u can move this var out of the for-loop scope

##########
File path: pkg/config/config_load.go
##########
@@ -168,22 +183,22 @@ func YAMLConfigLoad(path string) *model.Bootstrap {
                }
                c.Lb = model.LbPolicy(lbPolicy)
        }
-
-       return cfg
 }
 
-// DefaultConfigLoad if not config, will load this
-func DefaultConfigLoad(path string) *model.Bootstrap {
-       log.Println("load config from : ", path)
-       content, err := ioutil.ReadFile(path)
-       if err != nil {
-               log.Fatalln("[config] [default load] load config failed, ", err)
-       }
-       cfg := &model.Bootstrap{}
-       // translate to lower case
-       err = json.Unmarshal(content, cfg)
-       if err != nil {
-               log.Fatalln("[config] [default load] json unmarshal config 
failed, ", err)
+func DiscoverType(cfg *model.Bootstrap) {
+       var discoverType int32
+       for _, c := range cfg.StaticResources.Clusters {
+               if c.TypeStr != "" {
+                       if t, ok := model.DiscoveryTypeValue[c.TypeStr]; ok {
+                               discoverType = t
+                       } else {
+                               c.TypeStr = "EDS"
+                               discoverType = 
model.DiscoveryTypeValue[c.TypeStr]
+                       }
+               } else {
+                       c.TypeStr = "EDS"
+                       discoverType = model.DiscoveryTypeValue[c.TypeStr]
+               }

Review comment:
       
   ```go   
                     flag := false         
                     if c.TypeStr != "" {
                        if t, ok := model.DiscoveryTypeValue[c.TypeStr]; ok {
                                discoverType = t
                                      flag = true
                        } 
                } 
                    if flag {
                        c.TypeStr = "EDS"
                        discoverType = model.DiscoveryTypeValue[c.TypeStr]
                }
   ```




-- 
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.

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to