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/11 11:37:55 UTC

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

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



##########
File path: cluster/router/chain/chain.go
##########
@@ -65,6 +65,15 @@ func (c *RouterChain) Route(invoker []protocol.Invoker, url *common.URL, invocat
 	return finalInvokers
 }
 
+// Notify router chain of the initial addresses from registry at the first time. Notify whenever addresses in registry change.
+func (c *RouterChain) SetInvokers(invokers []protocol.Invoker) {

Review comment:
       Your comment may start with func name.

##########
File path: cluster/router/tag/router_rule.go
##########
@@ -22,9 +22,27 @@ import (
 	"github.com/apache/dubbo-go/common/yaml"
 )
 
+/**
+ * %YAML1.2
+ * ---
+ * force: true
+ * runtime: false
+ * enabled: true
+ * priority: 1
+ * key: demo-provider
+ * tags:
+ * - name: tag1
+ * addresses: [ip1, ip2]
+ * - name: tag2
+ * addresses: [ip3, ip4]
+ * ...
+ */
 // RouterRule RouterRule config read from config file or config center
 type RouterRule struct {
-	router.BaseRouterRule `yaml:",inline"`
+	router.BaseRouterRule `yaml:",inline""`

Review comment:
       I saw three " , is this right?

##########
File path: cluster/router/tag/router_rule.go
##########
@@ -34,5 +52,54 @@ func getRule(rawRule string) (*RouterRule, error) {
 		return r, err
 	}
 	r.RawRule = rawRule
+	r.init()
 	return r, nil
 }
+
+// init use for flattening tags data to @addressToTagNames and @tagNameToAddresses
+func (t *RouterRule) init() {
+	t.addressToTagNames = make(map[string][]string, 2*len(t.Tags))

Review comment:
       I do not think named `init` is golang native.  Because `init` is golang's  special func. Maybe   func (t *RouterRule)NewRouterRule is .

##########
File path: cluster/router/tag/tag.go
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tag
+
+type Tag struct {
+	Name      string
+	Addresses []string
+}
+

Review comment:
       I do not think golang need 'getXXX' . 




----------------------------------------------------------------
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