cityiron commented on a change in pull request #171:
URL: https://github.com/apache/dubbo-go-pixiu/pull/171#discussion_r636583397



##########
File path: pkg/config/api_config.go
##########
@@ -67,64 +80,116 @@ func LoadAPIConfigFromFile(path string) (*fc.APIConfig, 
error) {
 
 // LoadAPIConfig load the api config from config center
 func LoadAPIConfig(metaConfig *model.APIMetaConfig) (*fc.APIConfig, error) {
-       client = etcdv3.NewConfigClient(
+       client, _ = etcdv3.NewConfigClientWithErr(
                etcdv3.WithName(etcdv3.RegistryETCDV3Client),
                etcdv3.WithTimeout(10*time.Second),
                etcdv3.WithEndpoints(strings.Split(metaConfig.Address, ",")...),
        )
 
-       go listenAPIConfigNodeEvent(metaConfig.APIConfigPath)
-
-       content, err := client.Get(metaConfig.APIConfigPath)
+       kList, vList, err := client.GetChildren(metaConfig.APIConfigPath)
        if err != nil {
                return nil, perrors.Errorf("Get remote config fail error %v", 
err)
        }
-
-       if err = initAPIConfigFromString(content); err != nil {
+       if err = initAPIConfigFromKVList(kList, vList); err != nil {
                return nil, err
        }
+       // TODO: 其他需要从远端获取配置的初始化操作

Review comment:
       use english

##########
File path: pkg/config/api_config.go
##########
@@ -18,36 +18,49 @@
 package config
 
 import (
+       "go.etcd.io/etcd/clientv3"

Review comment:
       split

##########
File path: pkg/config/api_config.go
##########
@@ -67,64 +80,116 @@ func LoadAPIConfigFromFile(path string) (*fc.APIConfig, 
error) {
 
 // LoadAPIConfig load the api config from config center
 func LoadAPIConfig(metaConfig *model.APIMetaConfig) (*fc.APIConfig, error) {
-       client = etcdv3.NewConfigClient(
+       client, _ = etcdv3.NewConfigClientWithErr(
                etcdv3.WithName(etcdv3.RegistryETCDV3Client),
                etcdv3.WithTimeout(10*time.Second),
                etcdv3.WithEndpoints(strings.Split(metaConfig.Address, ",")...),
        )
 
-       go listenAPIConfigNodeEvent(metaConfig.APIConfigPath)
-
-       content, err := client.Get(metaConfig.APIConfigPath)
+       kList, vList, err := client.GetChildren(metaConfig.APIConfigPath)
        if err != nil {
                return nil, perrors.Errorf("Get remote config fail error %v", 
err)
        }
-
-       if err = initAPIConfigFromString(content); err != nil {
+       if err = initAPIConfigFromKVList(kList, vList); err != nil {
                return nil, err
        }
+       // TODO: 其他需要从远端获取配置的初始化操作
 
+       go listenResourceAndMethodEvent(metaConfig.APIConfigPath)
+       // TODO: 其他监控配置的操作,比如 PluginGroup 等
        return apiConfig, nil
 }
 
-func initAPIConfigFromString(content string) error {
+func initAPIConfigFromKVList(kList, vList []string) error {

Review comment:
       make handle resource and handle method two method may be better
    




-- 
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to