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 2021/05/04 04:45:26 UTC

[GitHub] [dubbo-go] LaurenceLiZhixin opened a new pull request #1187: Feat: add v3router to dubbogo

LaurenceLiZhixin opened a new pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187


   <!--  Thanks for sending a pull request!
   Read https://github.com/apache/dubbo-go/blob/master/contributing.md before commit pull request.
   -->
   
   **What this PR does**:
   
   **Which issue(s) this PR fixes**:
   <!--
   *Automatically closes linked issue when PR is merged.
   Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
   _If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
   -->
   Fixes #
   
   **Special notes for your reviewer**:
   
   **Does this PR introduce a user-facing change?**:
   <!--
   If no, just write "NONE" in the release-note block below.
   If yes, a release note is required:
   Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
   -->
   ```release-note
   
   ```


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


[GitHub] [dubbo-go] LaurenceLiZhixin commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
LaurenceLiZhixin commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r628744316



##########
File path: cluster/router/v3router/judger/attachment_match_judger.go
##########
@@ -0,0 +1,80 @@
+/*
+ * 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 judger
+
+import (
+	"github.com/apache/dubbo-go/config"
+	"github.com/apache/dubbo-go/protocol"
+)
+
+type AttachmentMatchJudger struct {
+	config.DubboAttachmentMatch
+}
+
+// nolint
+func (amj *AttachmentMatchJudger) Judge(invocation protocol.Invocation) bool {
+	invAttaMap := invocation.Attachments()
+	if amj.EagleeyeContext != nil {
+		for k, v := range amj.EagleeyeContext {
+			invAttaValue, ok := invAttaMap[k]
+			if !ok {
+				if v.Empty == "" {
+					return false
+				}
+			}
+			// exist this key
+			str, ok := invAttaValue.(string)
+			if !ok {
+				return false
+			}
+			strJudger := NewStringMatchJudger(v)
+			if !strJudger.Judge(str) {
+				return false
+			}
+		}
+	}
+
+	if amj.DubboContext != nil {
+		for k, v := range amj.DubboContext {
+			invAttaValue, ok := invAttaMap[k]
+			if !ok {
+				if v.Empty == "" {
+					return false
+				}
+			}
+			// exist this key
+			str, ok := invAttaValue.(string)

Review comment:
       Yes I fixed 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


[GitHub] [dubbo-go] codecov-commenter commented on pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#issuecomment-833496135


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1187](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9f7ec6a) into [3.0](https://codecov.io/gh/apache/dubbo-go/commit/968650f658b63c11bb0409897d29c57b91cfaf50?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (968650f) will **decrease** coverage by `3.61%`.
   > The diff coverage is `51.04%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/1187/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##              3.0    #1187      +/-   ##
   ==========================================
   - Coverage   59.53%   55.92%   -3.62%     
   ==========================================
     Files         259      269      +10     
     Lines       12737    12816      +79     
   ==========================================
   - Hits         7583     7167     -416     
   - Misses       4199     4758     +559     
   + Partials      955      891      -64     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [cluster/cluster\_impl/available\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYXZhaWxhYmxlX2NsdXN0ZXIuZ28=) | `100.00% <ø> (ø)` | |
   | [cluster/cluster\_impl/broadcast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYnJvYWRjYXN0X2NsdXN0ZXJfaW52b2tlci5nbw==) | `76.47% <ø> (ø)` | |
   | [cluster/cluster\_impl/failfast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvZmFpbGZhc3RfY2x1c3Rlcl9pbnZva2VyLmdv) | `66.66% <ø> (ø)` | |
   | [cluster/cluster\_impl/mock\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvbW9ja19jbHVzdGVyLmdv) | `0.00% <0.00%> (ø)` | |
   | [cluster/loadbalance/random.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS9yYW5kb20uZ28=) | `100.00% <ø> (ø)` | |
   | [.../v3router/match\_judger/list\_string\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvbWF0Y2hfanVkZ2VyL2xpc3Rfc3RyaW5nX21hdGNoX2p1ZGdlci5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...outer/v3router/match\_judger/method\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvbWF0Y2hfanVkZ2VyL21ldGhvZF9tYXRjaF9qdWRnZXIuZ28=) | `0.00% <0.00%> (ø)` | |
   | [...ter/v3router/match\_judger/url\_label\_match\_judge.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvbWF0Y2hfanVkZ2VyL3VybF9sYWJlbF9tYXRjaF9qdWRnZS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [common/extension/cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jbHVzdGVyLmdv) | `0.00% <ø> (ø)` | |
   | [common/extension/config\_center.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jb25maWdfY2VudGVyLmdv) | `0.00% <ø> (ø)` | |
   | ... and [252 more](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3180469...9f7ec6a](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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


[GitHub] [dubbo-go] wongoo commented on pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
wongoo commented on pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#issuecomment-835357244


   > > judger的设计直接依赖于config配置,在运行时依据配置进行判断,都是重复性的工作,看这部分是不是可以优化。每个judger只需依赖自己需要的信息即可。
   > 
   > 目前来说每个judger是只依赖自己的需要的信息。望哥的意思是不直接依赖于配置?让每个judger自己保存关心的字段么?我觉得可以之后优化一下。
   
   是的,可以后续优化


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


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#issuecomment-833496135


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1187](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (940194d) into [3.0](https://codecov.io/gh/apache/dubbo-go/commit/968650f658b63c11bb0409897d29c57b91cfaf50?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (968650f) will **decrease** coverage by `3.54%`.
   > The diff coverage is `51.66%`.
   
   > :exclamation: Current head 940194d differs from pull request most recent head c603af6. Consider uploading reports for the commit c603af6 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/1187/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##              3.0    #1187      +/-   ##
   ==========================================
   - Coverage   59.53%   55.99%   -3.55%     
   ==========================================
     Files         259      269      +10     
     Lines       12737    12816      +79     
   ==========================================
   - Hits         7583     7176     -407     
   - Misses       4199     4747     +548     
   + Partials      955      893      -62     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [cluster/cluster\_impl/available\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYXZhaWxhYmxlX2NsdXN0ZXIuZ28=) | `100.00% <ø> (ø)` | |
   | [cluster/cluster\_impl/broadcast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYnJvYWRjYXN0X2NsdXN0ZXJfaW52b2tlci5nbw==) | `76.47% <ø> (ø)` | |
   | [cluster/cluster\_impl/failfast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvZmFpbGZhc3RfY2x1c3Rlcl9pbnZva2VyLmdv) | `66.66% <ø> (ø)` | |
   | [cluster/cluster\_impl/mock\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvbW9ja19jbHVzdGVyLmdv) | `0.00% <0.00%> (ø)` | |
   | [cluster/loadbalance/random.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS9yYW5kb20uZ28=) | `100.00% <ø> (ø)` | |
   | [...router/v3router/judger/list\_string\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL2xpc3Rfc3RyaW5nX21hdGNoX2p1ZGdlci5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...ster/router/v3router/judger/method\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL21ldGhvZF9tYXRjaF9qdWRnZXIuZ28=) | `0.00% <0.00%> (ø)` | |
   | [...er/router/v3router/judger/url\_label\_match\_judge.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL3VybF9sYWJlbF9tYXRjaF9qdWRnZS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [common/extension/cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jbHVzdGVyLmdv) | `0.00% <ø> (ø)` | |
   | [common/extension/config\_center.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jb25maWdfY2VudGVyLmdv) | `0.00% <ø> (ø)` | |
   | ... and [252 more](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3180469...c603af6](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#issuecomment-833496135


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1187](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b368f68) into [3.0](https://codecov.io/gh/apache/dubbo-go/commit/968650f658b63c11bb0409897d29c57b91cfaf50?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (968650f) will **decrease** coverage by `3.54%`.
   > The diff coverage is `51.66%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/1187/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##              3.0    #1187      +/-   ##
   ==========================================
   - Coverage   59.53%   55.99%   -3.55%     
   ==========================================
     Files         259      269      +10     
     Lines       12737    12816      +79     
   ==========================================
   - Hits         7583     7176     -407     
   - Misses       4199     4747     +548     
   + Partials      955      893      -62     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [cluster/cluster\_impl/available\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYXZhaWxhYmxlX2NsdXN0ZXIuZ28=) | `100.00% <ø> (ø)` | |
   | [cluster/cluster\_impl/broadcast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYnJvYWRjYXN0X2NsdXN0ZXJfaW52b2tlci5nbw==) | `76.47% <ø> (ø)` | |
   | [cluster/cluster\_impl/failfast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvZmFpbGZhc3RfY2x1c3Rlcl9pbnZva2VyLmdv) | `66.66% <ø> (ø)` | |
   | [cluster/cluster\_impl/mock\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvbW9ja19jbHVzdGVyLmdv) | `0.00% <0.00%> (ø)` | |
   | [cluster/loadbalance/random.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS9yYW5kb20uZ28=) | `100.00% <ø> (ø)` | |
   | [...router/v3router/judger/list\_string\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL2xpc3Rfc3RyaW5nX21hdGNoX2p1ZGdlci5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...ster/router/v3router/judger/method\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL21ldGhvZF9tYXRjaF9qdWRnZXIuZ28=) | `0.00% <0.00%> (ø)` | |
   | [...er/router/v3router/judger/url\_label\_match\_judge.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL3VybF9sYWJlbF9tYXRjaF9qdWRnZS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [common/extension/cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jbHVzdGVyLmdv) | `0.00% <ø> (ø)` | |
   | [common/extension/config\_center.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jb25maWdfY2VudGVyLmdv) | `0.00% <ø> (ø)` | |
   | ... and [252 more](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3180469...b368f68](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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


[GitHub] [dubbo-go] wongoo commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
wongoo commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r628289662



##########
File path: cluster/router/v3router/judger/string_match_judger.go
##########
@@ -0,0 +1,60 @@
+/*
+ * 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 judger
+
+import (
+	"regexp"
+	"strings"
+)
+
+import (
+	"github.com/apache/dubbo-go/config"
+)
+
+// nolint
+type StringMatchJudger struct {
+	config.StringMatch
+}
+
+// nolint
+func (smj *StringMatchJudger) Judge(input string) bool {

Review comment:
       这个judge方法不是很高效,每次都要判断。是不是本身应该扩展出不同的judger,比如 `StringExactMatchJudger`, `StringPrefixMatchJudger`, `StringRegexMatchJudger` 等?




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


[GitHub] [dubbo-go] wongoo commented on pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
wongoo commented on pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#issuecomment-834517853


   judger的设计直接依赖于config配置,在运行时依据配置进行判断,都是重复性的工作,看这部分是不是可以优化。每个judger只需依赖自己需要的信息即可。


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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r627499727



##########
File path: cluster/router/v3router/router_chain.go
##########
@@ -0,0 +1,247 @@
+/*
+ * 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 v3router
+
+import (
+	"encoding/json"
+	"fmt"
+	"io"
+	"strings"
+)
+
+import (
+	"gopkg.in/yaml.v2"
+)
+
+import (
+	"github.com/apache/dubbo-go/cluster/router"
+	"github.com/apache/dubbo-go/cluster/router/v3router/k8s_api"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/config"
+	"github.com/apache/dubbo-go/config_center"
+	"github.com/apache/dubbo-go/protocol"
+	"github.com/apache/dubbo-go/remoting"
+)
+
+// RouterChain contains all uniform router logic
+// it has UniformRouter list,
+type RouterChain struct {
+	routers                    []*UniformRouter
+	virtualServiceConfigBytes  []byte
+	destinationRuleConfigBytes []byte
+	notify                     chan struct{}
+}
+
+// NewUniformRouterChain return
+func NewUniformRouterChain(virtualServiceConfig, destinationRuleConfig []byte, notify chan struct{}) (router.PriorityRouter, error) {
+	fromFileConfig := true
+	uniformRouters, err := parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig, notify)
+	if err != nil {
+		fromFileConfig = false
+		logger.Warnf("parse router config form local file failed, error = %+v", err)
+	}
+	r := &RouterChain{
+		virtualServiceConfigBytes:  virtualServiceConfig,
+		destinationRuleConfigBytes: destinationRuleConfig,
+		routers:                    uniformRouters,
+		notify:                     notify,
+	}
+	if err := k8s_api.SetK8sEventListener(r); err != nil {
+		logger.Warnf("try listen K8s router config failed, error = %+v", err)
+		if !fromFileConfig {
+			panic("No config file from both local file and k8s")
+		}
+	}
+	return r, nil
+}
+
+// Route route invokers using RouterChain's routers one by one
+func (r *RouterChain) Route(invokers []protocol.Invoker, url *common.URL, invocation protocol.Invocation) []protocol.Invoker {
+	for _, v := range r.routers {
+		invokers = v.Route(invokers, url, invocation)
+	}
+	return invokers
+}
+
+func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) {
+	logger.Debugf("on processed event = %+v\n", *event)
+	if event.ConfigType == remoting.EventTypeAdd || event.ConfigType == remoting.EventTypeUpdate {
+		switch event.Key {
+		case k8s_api.VirtualServiceEventKey:
+			logger.Debug("virtul service event")
+			newVSValue, ok := event.Value.(*config.VirtualServiceConfig)
+			if !ok {
+				logger.Error("event.Value assertion error")
+				return
+			}
+
+			newVSJsonValue, ok := newVSValue.ObjectMeta.Annotations["kubectl.kubernetes.io/last-applied-configuration"]
+			if !ok {
+				logger.Error("newVSValue.ObjectMeta.Annotations has no key named kubectl.kubernetes.io/last-applied-configuration")
+				return
+			}
+			logger.Debugf("json file = %v\n", newVSJsonValue)
+			newVirtualServiceConfig := &config.VirtualServiceConfig{}
+			if err := json.Unmarshal([]byte(newVSJsonValue), newVirtualServiceConfig); err != nil {
+				logger.Error("on process json data unmarshal error = ", err)
+				return
+			}
+			newVirtualServiceConfig.YamlAPIVersion = newVirtualServiceConfig.APIVersion
+			newVirtualServiceConfig.YamlKind = newVirtualServiceConfig.Kind
+			newVirtualServiceConfig.MetaData.Name = newVirtualServiceConfig.ObjectMeta.Name
+			fmt.Printf("get event after asseration = %+v\n", newVirtualServiceConfig)

Review comment:
       pls delete it or change it to logger.Debugf




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


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#issuecomment-833496135


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1187](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b368f68) into [3.0](https://codecov.io/gh/apache/dubbo-go/commit/968650f658b63c11bb0409897d29c57b91cfaf50?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (968650f) will **decrease** coverage by `3.54%`.
   > The diff coverage is `51.66%`.
   
   > :exclamation: Current head b368f68 differs from pull request most recent head 940194d. Consider uploading reports for the commit 940194d to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/1187/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##              3.0    #1187      +/-   ##
   ==========================================
   - Coverage   59.53%   55.99%   -3.55%     
   ==========================================
     Files         259      269      +10     
     Lines       12737    12816      +79     
   ==========================================
   - Hits         7583     7176     -407     
   - Misses       4199     4747     +548     
   + Partials      955      893      -62     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [cluster/cluster\_impl/available\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYXZhaWxhYmxlX2NsdXN0ZXIuZ28=) | `100.00% <ø> (ø)` | |
   | [cluster/cluster\_impl/broadcast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYnJvYWRjYXN0X2NsdXN0ZXJfaW52b2tlci5nbw==) | `76.47% <ø> (ø)` | |
   | [cluster/cluster\_impl/failfast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvZmFpbGZhc3RfY2x1c3Rlcl9pbnZva2VyLmdv) | `66.66% <ø> (ø)` | |
   | [cluster/cluster\_impl/mock\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvbW9ja19jbHVzdGVyLmdv) | `0.00% <0.00%> (ø)` | |
   | [cluster/loadbalance/random.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS9yYW5kb20uZ28=) | `100.00% <ø> (ø)` | |
   | [...router/v3router/judger/list\_string\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL2xpc3Rfc3RyaW5nX21hdGNoX2p1ZGdlci5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...ster/router/v3router/judger/method\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL21ldGhvZF9tYXRjaF9qdWRnZXIuZ28=) | `0.00% <0.00%> (ø)` | |
   | [...er/router/v3router/judger/url\_label\_match\_judge.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL3VybF9sYWJlbF9tYXRjaF9qdWRnZS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [common/extension/cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jbHVzdGVyLmdv) | `0.00% <ø> (ø)` | |
   | [common/extension/config\_center.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jb25maWdfY2VudGVyLmdv) | `0.00% <ø> (ø)` | |
   | ... and [252 more](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3180469...940194d](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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


[GitHub] [dubbo-go] LaurenceLiZhixin commented on pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
LaurenceLiZhixin commented on pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#issuecomment-835339148


   > 
   > 
   > judger的设计直接依赖于config配置,在运行时依据配置进行判断,都是重复性的工作,看这部分是不是可以优化。每个judger只需依赖自己需要的信息即可。
   
   目前来说每个judger是只依赖自己的需要的信息。望哥的意思是不直接依赖于配置?让每个judger自己保存关心的字段么?我觉得可以之后优化一下。


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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r628320829



##########
File path: cluster/router/v3router/judger/string_match_judger.go
##########
@@ -0,0 +1,60 @@
+/*
+ * 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 judger
+
+import (
+	"regexp"
+	"strings"
+)
+
+import (
+	"github.com/apache/dubbo-go/config"
+)
+
+// nolint
+type StringMatchJudger struct {
+	config.StringMatch
+}
+
+// nolint
+func (smj *StringMatchJudger) Judge(input string) bool {

Review comment:
       这个还好,没必要做过早优化。




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


[GitHub] [dubbo-go] AlexStocks merged pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks merged pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187


   


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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r627489002



##########
File path: cluster/router/v3router/k8s_api/listener_handler_impl.go
##########
@@ -0,0 +1,207 @@
+/*
+ * 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 k8s_api
+
+import (
+	"fmt"
+)
+
+import (
+	metav "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/runtime"
+	"k8s.io/apimachinery/pkg/watch"
+	"k8s.io/client-go/kubernetes/scheme"
+	"k8s.io/client-go/rest"
+)
+
+import (
+	"github.com/apache/dubbo-go/cluster/router/v3router/k8s_crd"
+	"github.com/apache/dubbo-go/config"
+	"github.com/apache/dubbo-go/config_center"
+	"github.com/apache/dubbo-go/remoting"
+)
+
+const (
+	VirtualServiceEventKey  = "virtualServiceEventKey"
+	DestinationRuleEventKey = "destinationRuleEventKe3y"
+
+	VirtualServiceResource = "virtualservices"
+	DestRuleResource       = "destinationrules"
+)
+
+// nolint
+type VirtualServiceListenerHandler struct {
+	listener config_center.ConfigurationListener
+}
+
+// nolint
+func (r *VirtualServiceListenerHandler) AddFunc(obj interface{}) {
+	//fmt.Println("addFunc")
+	if vsc, ok := obj.(*config.VirtualServiceConfig); ok {
+		fmt.Printf("in add func: get asserted VirtualServiceConfig = %+v\n", *vsc)
+		event := &config_center.ConfigChangeEvent{
+			Key:        VirtualServiceEventKey,
+			Value:      vsc,
+			ConfigType: remoting.EventTypeAdd,
+		}
+		r.listener.Process(event)
+	}
+}
+
+// nolint
+func (r *VirtualServiceListenerHandler) UpdateFunc(oldObj, newObj interface{}) {
+	//fmt.Println("update func = ")

Review comment:
       delete this comment 




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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r627491101



##########
File path: cluster/router/v3router/k8s_crd/client.go
##########
@@ -0,0 +1,135 @@
+/*
+ * 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 k8s_crd
+
+import (
+	"sync"
+	"time"
+)
+
+import (
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/runtime"
+	"k8s.io/apimachinery/pkg/runtime/schema"
+	"k8s.io/apimachinery/pkg/runtime/serializer"
+	"k8s.io/apimachinery/pkg/util/wait"
+	"k8s.io/apimachinery/pkg/watch"
+	"k8s.io/client-go/kubernetes/scheme"
+	"k8s.io/client-go/rest"
+	"k8s.io/client-go/tools/cache"
+)
+
+import (
+	"github.com/apache/dubbo-go/common/logger"
+)
+
+type Client struct {
+	rawClient           *rest.RESTClient
+	groupVersion        schema.GroupVersion
+	namespace           string
+	listenerHandlerList []ListenerHandler
+
+	once sync.Once
+}
+
+func (c *Client) addKnownTypes(scheme *runtime.Scheme) error {
+	for _, v := range c.listenerHandlerList {
+		scheme.AddKnownTypes(c.groupVersion,
+			v.GetObject(),
+		)
+	}
+
+	metav1.AddToGroupVersion(scheme, c.groupVersion)
+	return nil
+}
+
+// NewK8sCRDClient create an K8sCRD client, for target  CRD objects:  @objects
+// with given @groupname, @groupVersion, @namespace
+// list and watchFunction would be called by k8s informer
+func NewK8sCRDClient(groupName, groupVersion, namespace string, handlers ...ListenerHandler) (*Client, error) {
+	var config *rest.Config
+	var err error
+
+	config, err = rest.InClusterConfig()
+	if err != nil {
+		logger.Warn("InClusterConfig failed, can't get uniform router config from k8s")
+		return nil, err
+	}
+
+	newClient := &Client{
+		listenerHandlerList: handlers,
+		namespace:           namespace,
+		groupVersion:        schema.GroupVersion{Group: groupName, Version: groupVersion},
+		once:                sync.Once{},

Review comment:
       this line is meaningless




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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r627498391



##########
File path: cluster/router/v3router/match_judger/double_range_match_judger.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 match_judger

Review comment:
       最好不要在 package 名字里面使用下划线。如果能找到更合适的,尽量使用更合适的。譬如就直接叫 judger?




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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r627486869



##########
File path: cluster/router/v3router/factory.go
##########
@@ -0,0 +1,35 @@
+/*
+ * 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 v3router
+
+import (
+	"github.com/apache/dubbo-go/cluster/router"
+)
+
+// UniformRouteFactory is uniform router's factory
+type UniformRouteFactory struct{}
+
+// NewUniformRouterFactory construct a new PriorityRouterFactory

Review comment:
       constructs?




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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r627490030



##########
File path: cluster/router/v3router/k8s_api/listener_handler_impl.go
##########
@@ -0,0 +1,207 @@
+/*
+ * 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 k8s_api
+
+import (
+	"fmt"
+)
+
+import (
+	metav "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/runtime"
+	"k8s.io/apimachinery/pkg/watch"
+	"k8s.io/client-go/kubernetes/scheme"
+	"k8s.io/client-go/rest"
+)
+
+import (
+	"github.com/apache/dubbo-go/cluster/router/v3router/k8s_crd"
+	"github.com/apache/dubbo-go/config"
+	"github.com/apache/dubbo-go/config_center"
+	"github.com/apache/dubbo-go/remoting"
+)
+
+const (
+	VirtualServiceEventKey  = "virtualServiceEventKey"
+	DestinationRuleEventKey = "destinationRuleEventKe3y"
+
+	VirtualServiceResource = "virtualservices"
+	DestRuleResource       = "destinationrules"
+)
+
+// nolint
+type VirtualServiceListenerHandler struct {
+	listener config_center.ConfigurationListener
+}
+
+// nolint
+func (r *VirtualServiceListenerHandler) AddFunc(obj interface{}) {
+	//fmt.Println("addFunc")
+	if vsc, ok := obj.(*config.VirtualServiceConfig); ok {
+		fmt.Printf("in add func: get asserted VirtualServiceConfig = %+v\n", *vsc)
+		event := &config_center.ConfigChangeEvent{
+			Key:        VirtualServiceEventKey,
+			Value:      vsc,
+			ConfigType: remoting.EventTypeAdd,
+		}
+		r.listener.Process(event)
+	}
+}
+
+// nolint
+func (r *VirtualServiceListenerHandler) UpdateFunc(oldObj, newObj interface{}) {
+	//fmt.Println("update func = ")
+	if vsc, ok := newObj.(*config.VirtualServiceConfig); ok {
+		event := &config_center.ConfigChangeEvent{
+			Key:        VirtualServiceEventKey,
+			Value:      vsc,
+			ConfigType: remoting.EventTypeUpdate,
+		}
+		r.listener.Process(event)
+	}
+
+}
+
+// nolint
+func (r *VirtualServiceListenerHandler) DeleteFunc(obj interface{}) {
+	if vsc, ok := obj.(*config.VirtualServiceConfig); ok {
+		event := &config_center.ConfigChangeEvent{
+			Key:        VirtualServiceEventKey,
+			Value:      vsc,
+			ConfigType: remoting.EventTypeDel,
+		}
+		r.listener.Process(event)
+	}
+}
+
+// nolint
+func (r *VirtualServiceListenerHandler) Watch(opts metav.ListOptions, restClient *rest.RESTClient, ns string) (watch.Interface, error) {
+	opts.Watch = true
+	return restClient.
+		Get().
+		Namespace(ns).
+		Resource(VirtualServiceResource).
+		VersionedParams(&opts, scheme.ParameterCodec).
+		Watch()
+}
+
+// nolint
+func (r *VirtualServiceListenerHandler) List(opts metav.ListOptions, restClient *rest.RESTClient, ns string) (runtime.Object, error) {
+	result := config.VirtualServiceConfigList{}
+	err := restClient.
+		Get().
+		Namespace(ns).
+		Resource(VirtualServiceResource).
+		VersionedParams(&opts, scheme.ParameterCodec).
+		Do().
+		Into(&result)
+
+	return &result, err
+}
+
+// nolint
+func (r *VirtualServiceListenerHandler) GetObject() runtime.Object {
+	return &config.VirtualServiceConfig{}
+}
+
+// nolint
+func newVirtualServiceListenerHandler(listener config_center.ConfigurationListener) k8s_crd.ListenerHandler {
+	return &VirtualServiceListenerHandler{
+		listener: listener,
+	}
+}
+
+// nolint
+type DestRuleListenerHandler struct {
+	listener config_center.ConfigurationListener
+}
+
+// nolint
+func (r *DestRuleListenerHandler) AddFunc(obj interface{}) {
+	if drc, ok := obj.(*config.DestinationRuleConfig); ok {
+		event := &config_center.ConfigChangeEvent{
+			Key:        DestinationRuleEventKey,
+			Value:      drc,
+			ConfigType: remoting.EventTypeAdd,
+		}
+		r.listener.Process(event)
+	}
+
+}
+
+// nolint
+func (r *DestRuleListenerHandler) UpdateFunc(oldObj, newObj interface{}) {
+	if drc, ok := newObj.(*config.DestinationRuleConfig); ok {
+		event := &config_center.ConfigChangeEvent{
+			Key:        DestinationRuleEventKey,
+			Value:      drc,
+			ConfigType: remoting.EventTypeUpdate,
+		}
+		r.listener.Process(event)
+	}
+}
+
+// nolint
+func (r *DestRuleListenerHandler) DeleteFunc(obj interface{}) {
+	if drc, ok := obj.(*config.DestinationRuleConfig); ok {
+		event := &config_center.ConfigChangeEvent{
+			Key:        DestinationRuleEventKey,
+			Value:      drc,
+			ConfigType: remoting.EventTypeDel,
+		}
+		r.listener.Process(event)
+	}
+}
+
+// nolint
+func (r *DestRuleListenerHandler) Watch(opts metav.ListOptions, restClient *rest.RESTClient, ns string) (watch.Interface, error) {
+	//fmt.Println("dest rule Call Watch")
+	opts.Watch = true
+	return restClient.
+		Get().
+		Namespace(ns).
+		Resource(DestRuleResource).
+		VersionedParams(&opts, scheme.ParameterCodec).
+		Watch()
+}
+
+// nolint
+func (r *DestRuleListenerHandler) List(opts metav.ListOptions, restClient *rest.RESTClient, ns string) (runtime.Object, error) {
+	//fmt.Println("Call List")

Review comment:
       delete this comment




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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r627501685



##########
File path: cluster/router/v3router/uniform_rule.go
##########
@@ -0,0 +1,257 @@
+/*
+ * 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 v3router
+
+import (
+	"math/rand"
+	"time"
+)
+
+import (
+	perrors "github.com/pkg/errors"
+)
+
+import (
+	"github.com/apache/dubbo-go/cluster/router/v3router/match_judger"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/config"
+	"github.com/apache/dubbo-go/protocol"
+)
+
+// VirtualServiceRule is item of virtual service, it aims at judge if invocation context match it's condition, and
+// if match, get result destination key, which should be defined in DestinationRule yaml file
+type VirtualServiceRule struct {
+	// routerItem store match router list and destination list of this router
+	routerItem *config.DubboServiceRouterItem
+
+	// uniformRule is the upper struct ptr
+	uniformRule *UniformRule
+}
+
+// match read from vsr's Match config
+// it judges if this invocation matches the router rule request defined in config one by one
+func (vsr *VirtualServiceRule) match(url *common.URL, invocation protocol.Invocation) bool {
+	for _, v := range vsr.routerItem.Match {
+		// method match judge
+		if v.Method != nil {
+			methodMatchJudger := match_judger.NewMethodMatchJudger(v.Method)
+			if !methodMatchJudger.Judge(invocation) {
+				return false
+			}
+		}
+
+		// source label match judge
+		if !match_judger.JudgeUrlLabel(url, v.SourceLabels) {
+			return false
+		}
+
+		// atta match judge
+		if v.Attachment != nil {
+			attachmentMatchJudger := match_judger.NewAttachmentMatchJudger(v.Attachment)
+			if attachmentMatchJudger.Judge(invocation) {
+				return false
+			}
+		}
+		// threshold match judge
+		// todo
+
+		// reserve match judge
+		// todo
+	}
+	return true
+}
+
+// tryGetSubsetFromRouterOfOneDestination is a recursion function
+// try from destination 's header to final fallback destination, when success, it return result destination, else return error
+func (vsr *VirtualServiceRule) tryGetSubsetFromRouterOfOneDestination(desc *config.DubboDestination, invokers []protocol.Invoker) ([]protocol.Invoker, int, error) {
+	subSet := desc.Destination.Subset
+	labels, ok := vsr.uniformRule.DestinationLabelListMap[subSet]
+	resultInvokers := make([]protocol.Invoker, 0)
+	if ok {
+		for _, v := range invokers {
+			if match_judger.JudgeUrlLabel(v.GetURL(), labels) {
+				resultInvokers = append(resultInvokers, v)
+			}
+		}
+		if len(resultInvokers) != 0 {
+			return resultInvokers, desc.Destination.Weight, nil
+		}
+	}
+
+	if desc.Destination.Fallback != nil {
+		return vsr.tryGetSubsetFromRouterOfOneDestination(desc.Destination.Fallback, invokers)
+	}
+	return nil, 0, perrors.New("No invoker matches and no fallback destination to choose!")
+}
+
+//weightInvokersPair stores weight and invoker list.
+type weightInvokersPair struct {
+	weight      int
+	invokerList []protocol.Invoker
+}
+
+type weightInvokerPairResults struct {
+	pairs []weightInvokersPair
+}
+
+func (w *weightInvokerPairResults) getTargetInvokers() []protocol.Invoker {
+	if len(w.pairs) == 0 {
+		return []protocol.Invoker{}
+	}
+
+	if len(w.pairs) == 1 {
+		return w.pairs[0].invokerList
+	}
+	rand.Seed(time.Now().UnixNano())
+	target := rand.Intn(100)
+	// noweight means all weigh is zero, random choose one invoker list
+	noWeight := true
+	// check if empty
+	for _, v := range w.pairs {
+		if v.weight != 0 {
+			noWeight = false // user defined weight
+			break
+		}
+	}
+	if noWeight {
+		// random choose one list
+		weitUnit := 100/len(w.pairs) + 1
+		return w.pairs[target/weitUnit].invokerList
+	} else {
+		total := 0
+		for _, v := range w.pairs {
+			total += v.weight
+			if total > target {
+				return v.invokerList
+			}
+		}
+	}
+	// invalid weight set: total is smaller than 100, choose first
+	return w.pairs[0].invokerList
+}
+
+func (vsr *VirtualServiceRule) getRuleTargetInvokers(invokers []protocol.Invoker) ([]protocol.Invoker, error) {
+	// weightInvokerPairResult is the collection routerDesc of all destination fields,
+	weightInvokerPairResult := weightInvokerPairResults{}
+	for _, v := range vsr.routerItem.Router {
+		// v is one destination 's header e.g.
+		/*
+			   route:
+				 - destination:      # v is here
+					 host: demo
+					 subset: v1
+				   fallback:
+					 destination:
+					   host: demo
+					   subset: v2
+					 fallback:
+					   destination:
+						 host: demo
+						 subset: v3
+				 - destination:
+					 host: demo
+					 subset: v4
+				   fallback:
+					 destination:
+					   host: demo
+					   subset: v5
+					 fallback:
+					   destination:
+						 host: demo
+						 subset: v6
+		*/
+		invokerListOfOneDest, weight, err := vsr.tryGetSubsetFromRouterOfOneDestination(v, invokers)
+		if err != nil {
+			return nil, err
+		}
+		// combination of all destination field e.g.
+		/*
+			 - destination:
+			   host: demo
+			   subset: na61
+			- destination:
+			   host: demo
+			   subset: na610
+		*/
+		weightInvokerPairResult.pairs = append(weightInvokerPairResult.pairs, weightInvokersPair{
+			weight:      weight,
+			invokerList: invokerListOfOneDest,
+		})
+	}
+
+	return weightInvokerPairResult.getTargetInvokers(), nil
+}
+
+// UniformRule
+type UniformRule struct {
+	services                []*config.StringMatch
+	virtualServiceRules     []VirtualServiceRule
+	DestinationLabelListMap map[string]map[string]string
+}
+
+// NewDefaultConnChecker constructs a new DefaultConnChecker based on the url
+func newUniformRule(dubboRoute *config.DubboRoute, destinationMap map[string]map[string]string) (*UniformRule, error) {
+	matchItems := dubboRoute.RouterDetail
+	virtualServiceRules := make([]VirtualServiceRule, 0)
+	newUniformRule := &UniformRule{
+		DestinationLabelListMap: destinationMap,
+		services:                dubboRoute.Services,
+	}
+	for _, v := range matchItems {
+		virtualServiceRules = append(virtualServiceRules, VirtualServiceRule{
+			routerItem:  v,
+			uniformRule: newUniformRule,
+		})
+	}
+	newUniformRule.virtualServiceRules = virtualServiceRules
+	return newUniformRule, nil
+}
+
+func (u *UniformRule) route(invokers []protocol.Invoker, url *common.URL, invocation protocol.Invocation) []protocol.Invoker {
+	// service rule + destination -> filter
+	resultInvokers := make([]protocol.Invoker, 0)
+	var err error
+	matchService := false
+	for _, v := range u.services {
+		// check if match service field
+		if match_judger.NewStringMatchJudger(v).Judge(url.ServiceKey()) {
+			matchService = true
+			break
+		}
+	}
+	if !matchService {
+		// if not match, jump this rule
+		return resultInvokers
+	}
+	// match service field, route Details level(service level) match
+	// then, check all sub rule, if match, get destination rule target invokers, else do fail back logic
+	for _, rule := range u.virtualServiceRules {
+		if rule.match(url, invocation) {
+			// match this rule, do get target logic
+			resultInvokers, err = rule.getRuleTargetInvokers(invokers)
+			if err != nil {
+				logger.Error("getRuleTargetInvokers from rule err = ", err)
+				return nil
+			}
+			return resultInvokers
+		}
+	}
+	logger.Error("no match rule!")

Review comment:
       logger.Error("no match rule for invokers %+v", invokers)




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


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#issuecomment-833496135


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1187](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (940194d) into [3.0](https://codecov.io/gh/apache/dubbo-go/commit/968650f658b63c11bb0409897d29c57b91cfaf50?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (968650f) will **decrease** coverage by `3.54%`.
   > The diff coverage is `51.66%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/1187/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##              3.0    #1187      +/-   ##
   ==========================================
   - Coverage   59.53%   55.99%   -3.55%     
   ==========================================
     Files         259      269      +10     
     Lines       12737    12816      +79     
   ==========================================
   - Hits         7583     7176     -407     
   - Misses       4199     4747     +548     
   + Partials      955      893      -62     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [cluster/cluster\_impl/available\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYXZhaWxhYmxlX2NsdXN0ZXIuZ28=) | `100.00% <ø> (ø)` | |
   | [cluster/cluster\_impl/broadcast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYnJvYWRjYXN0X2NsdXN0ZXJfaW52b2tlci5nbw==) | `76.47% <ø> (ø)` | |
   | [cluster/cluster\_impl/failfast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvZmFpbGZhc3RfY2x1c3Rlcl9pbnZva2VyLmdv) | `66.66% <ø> (ø)` | |
   | [cluster/cluster\_impl/mock\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvbW9ja19jbHVzdGVyLmdv) | `0.00% <0.00%> (ø)` | |
   | [cluster/loadbalance/random.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS9yYW5kb20uZ28=) | `100.00% <ø> (ø)` | |
   | [...router/v3router/judger/list\_string\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL2xpc3Rfc3RyaW5nX21hdGNoX2p1ZGdlci5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...ster/router/v3router/judger/method\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL21ldGhvZF9tYXRjaF9qdWRnZXIuZ28=) | `0.00% <0.00%> (ø)` | |
   | [...er/router/v3router/judger/url\_label\_match\_judge.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL3VybF9sYWJlbF9tYXRjaF9qdWRnZS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [common/extension/cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jbHVzdGVyLmdv) | `0.00% <ø> (ø)` | |
   | [common/extension/config\_center.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jb25maWdfY2VudGVyLmdv) | `0.00% <ø> (ø)` | |
   | ... and [252 more](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3180469...940194d](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#issuecomment-833496135


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1187](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (fd5aa59) into [3.0](https://codecov.io/gh/apache/dubbo-go/commit/968650f658b63c11bb0409897d29c57b91cfaf50?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (968650f) will **decrease** coverage by `3.59%`.
   > The diff coverage is `51.58%`.
   
   > :exclamation: Current head fd5aa59 differs from pull request most recent head c603af6. Consider uploading reports for the commit c603af6 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/1187/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##              3.0    #1187      +/-   ##
   ==========================================
   - Coverage   59.53%   55.94%   -3.60%     
   ==========================================
     Files         259      269      +10     
     Lines       12737    12818      +81     
   ==========================================
   - Hits         7583     7171     -412     
   - Misses       4199     4753     +554     
   + Partials      955      894      -61     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [cluster/cluster\_impl/available\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYXZhaWxhYmxlX2NsdXN0ZXIuZ28=) | `100.00% <ø> (ø)` | |
   | [cluster/cluster\_impl/broadcast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYnJvYWRjYXN0X2NsdXN0ZXJfaW52b2tlci5nbw==) | `76.47% <ø> (ø)` | |
   | [cluster/cluster\_impl/failfast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvZmFpbGZhc3RfY2x1c3Rlcl9pbnZva2VyLmdv) | `66.66% <ø> (ø)` | |
   | [cluster/cluster\_impl/mock\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvbW9ja19jbHVzdGVyLmdv) | `0.00% <0.00%> (ø)` | |
   | [cluster/loadbalance/random.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS9yYW5kb20uZ28=) | `100.00% <ø> (ø)` | |
   | [...router/v3router/judger/list\_string\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL2xpc3Rfc3RyaW5nX21hdGNoX2p1ZGdlci5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...ster/router/v3router/judger/method\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL21ldGhvZF9tYXRjaF9qdWRnZXIuZ28=) | `0.00% <0.00%> (ø)` | |
   | [...er/router/v3router/judger/url\_label\_match\_judge.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvanVkZ2VyL3VybF9sYWJlbF9tYXRjaF9qdWRnZS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [common/extension/cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jbHVzdGVyLmdv) | `0.00% <ø> (ø)` | |
   | [common/extension/config\_center.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jb25maWdfY2VudGVyLmdv) | `0.00% <ø> (ø)` | |
   | ... and [254 more](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3180469...c603af6](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r627488376



##########
File path: cluster/router/v3router/k8s_api/k8s.go
##########
@@ -0,0 +1,40 @@
+/*
+ * 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 k8s_api
+
+import (
+	"github.com/apache/dubbo-go/cluster/router/v3router/k8s_crd"
+	"github.com/apache/dubbo-go/config_center"
+)
+
+const (
+	GroupName    = "service.dubbo.apache.org"
+	GroupVersion = "v1alpha1"
+	Namespace    = "dubbo-workplace"
+)
+
+func SetK8sEventListener(listener config_center.ConfigurationListener) error {
+	vsUniformRouterListenerHandler := newVirtualServiceListenerHandler(listener)
+	drUniformRouterListenerHandler := newDestRuleListenerHandler(listener)
+	k8sCRDClient, err := k8s_crd.NewK8sCRDClient(GroupName, GroupVersion, Namespace, vsUniformRouterListenerHandler, drUniformRouterListenerHandler)

Review comment:
       pls split this so long line




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


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r627500030



##########
File path: cluster/router/v3router/router_chain.go
##########
@@ -0,0 +1,247 @@
+/*
+ * 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 v3router
+
+import (
+	"encoding/json"
+	"fmt"
+	"io"
+	"strings"
+)
+
+import (
+	"gopkg.in/yaml.v2"
+)
+
+import (
+	"github.com/apache/dubbo-go/cluster/router"
+	"github.com/apache/dubbo-go/cluster/router/v3router/k8s_api"
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/config"
+	"github.com/apache/dubbo-go/config_center"
+	"github.com/apache/dubbo-go/protocol"
+	"github.com/apache/dubbo-go/remoting"
+)
+
+// RouterChain contains all uniform router logic
+// it has UniformRouter list,
+type RouterChain struct {
+	routers                    []*UniformRouter
+	virtualServiceConfigBytes  []byte
+	destinationRuleConfigBytes []byte
+	notify                     chan struct{}
+}
+
+// NewUniformRouterChain return
+func NewUniformRouterChain(virtualServiceConfig, destinationRuleConfig []byte, notify chan struct{}) (router.PriorityRouter, error) {
+	fromFileConfig := true
+	uniformRouters, err := parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig, notify)
+	if err != nil {
+		fromFileConfig = false
+		logger.Warnf("parse router config form local file failed, error = %+v", err)
+	}
+	r := &RouterChain{
+		virtualServiceConfigBytes:  virtualServiceConfig,
+		destinationRuleConfigBytes: destinationRuleConfig,
+		routers:                    uniformRouters,
+		notify:                     notify,
+	}
+	if err := k8s_api.SetK8sEventListener(r); err != nil {
+		logger.Warnf("try listen K8s router config failed, error = %+v", err)
+		if !fromFileConfig {
+			panic("No config file from both local file and k8s")
+		}
+	}
+	return r, nil
+}
+
+// Route route invokers using RouterChain's routers one by one
+func (r *RouterChain) Route(invokers []protocol.Invoker, url *common.URL, invocation protocol.Invocation) []protocol.Invoker {
+	for _, v := range r.routers {
+		invokers = v.Route(invokers, url, invocation)
+	}
+	return invokers
+}
+
+func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) {
+	logger.Debugf("on processed event = %+v\n", *event)
+	if event.ConfigType == remoting.EventTypeAdd || event.ConfigType == remoting.EventTypeUpdate {
+		switch event.Key {
+		case k8s_api.VirtualServiceEventKey:
+			logger.Debug("virtul service event")
+			newVSValue, ok := event.Value.(*config.VirtualServiceConfig)
+			if !ok {
+				logger.Error("event.Value assertion error")
+				return
+			}
+
+			newVSJsonValue, ok := newVSValue.ObjectMeta.Annotations["kubectl.kubernetes.io/last-applied-configuration"]
+			if !ok {
+				logger.Error("newVSValue.ObjectMeta.Annotations has no key named kubectl.kubernetes.io/last-applied-configuration")
+				return
+			}
+			logger.Debugf("json file = %v\n", newVSJsonValue)
+			newVirtualServiceConfig := &config.VirtualServiceConfig{}
+			if err := json.Unmarshal([]byte(newVSJsonValue), newVirtualServiceConfig); err != nil {
+				logger.Error("on process json data unmarshal error = ", err)
+				return
+			}
+			newVirtualServiceConfig.YamlAPIVersion = newVirtualServiceConfig.APIVersion
+			newVirtualServiceConfig.YamlKind = newVirtualServiceConfig.Kind
+			newVirtualServiceConfig.MetaData.Name = newVirtualServiceConfig.ObjectMeta.Name
+			fmt.Printf("get event after asseration = %+v\n", newVirtualServiceConfig)
+			data, err := yaml.Marshal(newVirtualServiceConfig)
+			if err != nil {
+				logger.Error("Process change of virtual service: event.Value marshal error:", err)
+				return
+			}
+			r.routers, err = parseFromConfigToRouters(data, r.destinationRuleConfigBytes, r.notify)
+			if err != nil {
+				logger.Error("Process change of virtual service: parseFromConfigToRouters:", err)
+				return
+			}
+		case k8s_api.DestinationRuleEventKey:
+			logger.Debug("handling dest rule event")
+			newDRValue, ok := event.Value.(*config.DestinationRuleConfig)
+			if !ok {
+				logger.Error("event.Value assertion error")
+				return
+			}
+
+			newDRJsonValue, ok := newDRValue.ObjectMeta.Annotations["kubectl.kubernetes.io/last-applied-configuration"]
+			if !ok {
+				logger.Error("newVSValue.ObjectMeta.Annotations has no key named kubectl.kubernetes.io/last-applied-configuration")
+				return
+			}
+			newDestRuleConfig := &config.DestinationRuleConfig{}
+			if err := json.Unmarshal([]byte(newDRJsonValue), newDestRuleConfig); err != nil {
+				logger.Error("on process json data unmarshal error = ", err)
+				return
+			}
+			newDestRuleConfig.YamlAPIVersion = newDestRuleConfig.APIVersion
+			newDestRuleConfig.YamlKind = newDestRuleConfig.Kind
+			newDestRuleConfig.MetaData.Name = newDestRuleConfig.ObjectMeta.Name
+			fmt.Printf("get event after asseration = %+v\n", newDestRuleConfig)

Review comment:
       logger.Debugf




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


[GitHub] [dubbo-go] wongoo commented on a change in pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
wongoo commented on a change in pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#discussion_r628283009



##########
File path: cluster/router/v3router/judger/attachment_match_judger.go
##########
@@ -0,0 +1,80 @@
+/*
+ * 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 judger
+
+import (
+	"github.com/apache/dubbo-go/config"
+	"github.com/apache/dubbo-go/protocol"
+)
+
+type AttachmentMatchJudger struct {
+	config.DubboAttachmentMatch
+}
+
+// nolint
+func (amj *AttachmentMatchJudger) Judge(invocation protocol.Invocation) bool {
+	invAttaMap := invocation.Attachments()
+	if amj.EagleeyeContext != nil {
+		for k, v := range amj.EagleeyeContext {
+			invAttaValue, ok := invAttaMap[k]
+			if !ok {
+				if v.Empty == "" {
+					return false
+				}
+			}
+			// exist this key
+			str, ok := invAttaValue.(string)
+			if !ok {
+				return false
+			}
+			strJudger := NewStringMatchJudger(v)
+			if !strJudger.Judge(str) {
+				return false
+			}
+		}
+	}
+
+	if amj.DubboContext != nil {
+		for k, v := range amj.DubboContext {
+			invAttaValue, ok := invAttaMap[k]
+			if !ok {
+				if v.Empty == "" {
+					return false
+				}
+			}
+			// exist this key
+			str, ok := invAttaValue.(string)

Review comment:
       `invAttaValue` is nil when `ok==false`, is that correct?




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


[GitHub] [dubbo-go] codecov-commenter edited a comment on pull request #1187: Feat: add v3router to dubbogo

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1187:
URL: https://github.com/apache/dubbo-go/pull/1187#issuecomment-833496135


   # [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1187](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (fbd10c8) into [3.0](https://codecov.io/gh/apache/dubbo-go/commit/968650f658b63c11bb0409897d29c57b91cfaf50?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (968650f) will **decrease** coverage by `3.52%`.
   > The diff coverage is `51.81%`.
   
   > :exclamation: Current head fbd10c8 differs from pull request most recent head b368f68. Consider uploading reports for the commit b368f68 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/dubbo-go/pull/1187/graphs/tree.svg?width=650&height=150&src=pr&token=dcPE6RyFAL&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##              3.0    #1187      +/-   ##
   ==========================================
   - Coverage   59.53%   56.00%   -3.53%     
   ==========================================
     Files         259      269      +10     
     Lines       12737    12816      +79     
   ==========================================
   - Hits         7583     7178     -405     
   - Misses       4199     4747     +548     
   + Partials      955      891      -64     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [cluster/cluster\_impl/available\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYXZhaWxhYmxlX2NsdXN0ZXIuZ28=) | `100.00% <ø> (ø)` | |
   | [cluster/cluster\_impl/broadcast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvYnJvYWRjYXN0X2NsdXN0ZXJfaW52b2tlci5nbw==) | `76.47% <ø> (ø)` | |
   | [cluster/cluster\_impl/failfast\_cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvZmFpbGZhc3RfY2x1c3Rlcl9pbnZva2VyLmdv) | `66.66% <ø> (ø)` | |
   | [cluster/cluster\_impl/mock\_cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyX2ltcGwvbW9ja19jbHVzdGVyLmdv) | `0.00% <0.00%> (ø)` | |
   | [cluster/loadbalance/random.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS9yYW5kb20uZ28=) | `100.00% <ø> (ø)` | |
   | [.../v3router/match\_judger/list\_string\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvbWF0Y2hfanVkZ2VyL2xpc3Rfc3RyaW5nX21hdGNoX2p1ZGdlci5nbw==) | `0.00% <0.00%> (ø)` | |
   | [...outer/v3router/match\_judger/method\_match\_judger.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvbWF0Y2hfanVkZ2VyL21ldGhvZF9tYXRjaF9qdWRnZXIuZ28=) | `0.00% <0.00%> (ø)` | |
   | [...ter/v3router/match\_judger/url\_label\_match\_judge.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdjNyb3V0ZXIvbWF0Y2hfanVkZ2VyL3VybF9sYWJlbF9tYXRjaF9qdWRnZS5nbw==) | `0.00% <0.00%> (ø)` | |
   | [common/extension/cluster.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jbHVzdGVyLmdv) | `0.00% <ø> (ø)` | |
   | [common/extension/config\_center.go](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL2V4dGVuc2lvbi9jb25maWdfY2VudGVyLmdv) | `0.00% <ø> (ø)` | |
   | ... and [254 more](https://codecov.io/gh/apache/dubbo-go/pull/1187/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3180469...b368f68](https://codecov.io/gh/apache/dubbo-go/pull/1187?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


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