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 2020/08/05 14:33:07 UTC

[GitHub] [dubbo-go] hxmhlt commented on a change in pull request #665: Ftr: dynamic tag router

hxmhlt commented on a change in pull request #665:
URL: https://github.com/apache/dubbo-go/pull/665#discussion_r465770000



##########
File path: cluster/router/tag/router_rule.go
##########
@@ -34,5 +52,58 @@ func getRule(rawRule string) (*RouterRule, error) {
 		return r, err
 	}
 	r.RawRule = rawRule
+	r.init()
 	return r, nil
 }
+
+func (t *RouterRule) init() {
+	t.addressToTagNames = make(map[string][]string, 8)
+	t.tagNameToAddresses = make(map[string][]string, 8)
+	for _, tag := range t.Tags {
+		for _, address := range tag.Addresses {
+			t.addressToTagNames[address] = append(t.addressToTagNames[address], tag.Name)
+		}
+		t.tagNameToAddresses[tag.Name] = tag.Addresses
+	}
+}
+
+func (t *RouterRule) getAddresses() []string {
+	var result = make([]string, 0, 8*len(t.Tags))

Review comment:
       Pls add func comment for RouterRule

##########
File path: cluster/router/tag/router_rule.go
##########
@@ -34,5 +52,58 @@ func getRule(rawRule string) (*RouterRule, error) {
 		return r, err
 	}
 	r.RawRule = rawRule
+	r.init()
 	return r, nil
 }
+
+func (t *RouterRule) init() {

Review comment:
       Why create a new func named init? If you create the func ,pls add the comment for it.




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



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