dubbo-go icon indicating copy to clipboard operation
dubbo-go copied to clipboard

远程配置的key可以统一

Open zhaoyunxing92 opened this issue 5 years ago • 3 comments

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 image 在zk里面使用的constant.ConfigTimeoutKey但是在nacos里面使用的却是constant.TimeoutKey,etcd里面用的又是constant.ConfigTimeoutKey Why is this needed: 希望可以统一key,方便后面代码开发和阅读

zhaoyunxing92 avatar Dec 02 '21 08:12 zhaoyunxing92

sounds great.

AlexStocks avatar Dec 02 '21 10:12 AlexStocks

@chenjunwei

LaurenceLiZhixin avatar Feb 11 '22 14:02 LaurenceLiZhixin

相关pr https://github.com/apache/dubbo-go/pull/1759

jeffchanjunwei avatar Feb 21 '22 11:02 jeffchanjunwei