You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/09/06 07:39:20 UTC
[GitHub] [dubbo-go] chickenlj commented on a diff in pull request #2022: Fix service discovery related issues and add mesh proxy mode support
chickenlj commented on code in PR #2022:
URL: https://github.com/apache/dubbo-go/pull/2022#discussion_r963360785
##########
config/registry_config.go:
##########
@@ -167,6 +171,85 @@ func (c *RegistryConfig) toURL(roleType common.RoleType) (*common.URL, error) {
)
}
+func (c *RegistryConfig) toURLs(roleType common.RoleType) ([]*common.URL, error) {
+ address := c.translateRegistryAddress()
+ var urls []*common.URL
+ var err error
+ var registryURL *common.URL
+ if c.RegistryType == "service" {
+ // service discovery protocol
+ if registryURL, err = c.createNewURL(constant.ServiceRegistryProtocol, address, roleType); err == nil {
+ urls = append(urls, registryURL)
+ }
+ } else if c.RegistryType == "interface" {
+ if registryURL, err = c.createNewURL(constant.RegistryProtocol, address, roleType); err == nil {
+ urls = append(urls, registryURL)
+ }
+ } else if c.RegistryType == "all" {
+ if registryURL, err = c.createNewURL(constant.ServiceRegistryProtocol, address, roleType); err == nil {
+ urls = append(urls, registryURL)
+ }
+ if registryURL, err = c.createNewURL(constant.RegistryProtocol, address, roleType); err == nil {
+ urls = append(urls, registryURL)
+ }
+ } else {
+ if registryURL, err = c.createNewURL(constant.ServiceRegistryProtocol, address, roleType); err == nil {
+ urls = append(urls, registryURL)
+ }
+ }
+ return urls, err
+}
+
+func loadRegistries(registryIds []string, registries map[string]*RegistryConfig, roleType common.RoleType) []*common.URL {
+ var registryURLs []*common.URL
+ //trSlice := strings.Split(targetRegistries, ",")
+
+ for k, registryConf := range registries {
+ target := false
+
+ // if user not config targetRegistries, default load all
+ // Notice: in func "func Split(s, sep string) []string" comment:
+ // if s does not contain sep and sep is not empty, SplitAfter returns
+ // a slice of length 1 whose only element is s. So we have to add the
+ // condition when targetRegistries string is not set (it will be "" when not set)
+ if len(registryIds) == 0 || (len(registryIds) == 1 && registryIds[0] == "") {
+ target = true
+ } else {
+ // else if user config targetRegistries
+ for _, tr := range registryIds {
+ if tr == k {
+ target = true
+ break
+ }
+ }
+ }
+
+ if target {
+ if urls, err := registryConf.toURLs(roleType); err != nil {
+ logger.Errorf("The registry id: %s url is invalid, error: %#v", k, err)
+ panic(err)
Review Comment:
Yes, I think so. If one or more registries were specified and panic occurs when parsing them, then we should panic to stop the process from being started.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org