dubbo-go
dubbo-go copied to clipboard
远程配置的key可以统一
What would you like to be added:
目前发现RegistryConfig、MetadataReportConfig、CenterConfig的toURL都有自己的key导致到具体实现的方法key获取的时候需要转换对应的key,处理起来比较容易出错
func newNacosRegistry(url *common.URL) (registry.Registry, error) {
logger.Infof("[Nacos Registry] New nacos registry with url = %+v", url.ToMap())
// key transfer: registry -> nacos
url.SetParam(constant.NacosNamespaceID, url.GetParam(constant.RegistryNamespaceKey, ""))
url.SetParam(constant.NacosUsername, url.Username)
url.SetParam(constant.NacosPassword, url.Password)
url.SetParam(constant.NacosAccessKey, url.GetParam(constant.RegistryAccessKey, ""))
url.SetParam(constant.NacosSecretKey, url.GetParam(constant.RegistrySecretKey, ""))
url.SetParam(constant.TimeoutKey, url.GetParam(constant.RegistryTimeoutKey, ""))
url.SetParam(constant.NacosGroupKey, url.GetParam(constant.RegistryGroupKey, defaultGroup))
namingClient, err := nacos.NewNacosClientByURL(url)
if err != nil {
return &nacosRegistry{}, err
}
tmpRegistry := &nacosRegistry{
URL: url, // registry.group is recorded at this url
namingClient: namingClient,
registryUrls: []*common.URL{},
}
return tmpRegistry, nil
}
在比如超时时间问题,CenterConfig使用的key是constant.ConfigTimeoutKey
在zk里面使用的constant.ConfigTimeoutKey但是在nacos里面使用的却是constant.TimeoutKey,etcd里面用的又是constant.ConfigTimeoutKey
Why is this needed:
希望可以统一key,方便后面代码开发和阅读
sounds great.
@chenjunwei
相关pr https://github.com/apache/dubbo-go/pull/1759