-
Notifications
You must be signed in to change notification settings - Fork 929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ftr: add dynamic tag router #703
Conversation
@@ -36,5 +36,8 @@ cp ${zkJar} cluster/router/chain/zookeeper-4unittest/contrib/fatjar | |||
mkdir -p cluster/router/condition/zookeeper-4unittest/contrib/fatjar | |||
cp ${zkJar} cluster/router/condition/zookeeper-4unittest/contrib/fatjar | |||
|
|||
mkdir -p cluster/router/tag/zookeeper-4unittest/contrib/fatjar | |||
cp ${zkJar} cluster/router/tag/zookeeper-4unittest/contrib/fatjar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also apply this change to file https://github.com/apache/dubbo-go/blob/master/before_ut.bat.
cluster/router/tag/tag_router.go
Outdated
if matchIp(address, host, port) { | ||
return true | ||
} | ||
if address == net.JoinHostPort(constant.ANYHOST_VALUE, port) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
net.JoinHostPort(constant.ANYHOST_VALUE, port)
is independent of the cycle, so it may be better to assign it to a value before cycle starts.
var invokers []protocol.Invoker | ||
invokers = append(invokers, inv2, inv3, inv4, inv5) | ||
filterTag := func(invoker protocol.Invoker) bool { | ||
if invoker.GetUrl().GetParam(constant.Tagkey, "") == "beijing" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly return invoker.GetUrl().GetParam(constant.Tagkey, "") == "beijing"
.
assert.Equal(t, []protocol.Invoker{inv4, inv5}, res) | ||
flag := true | ||
filterEnabled := func(invoker protocol.Invoker) bool { | ||
if invoker.GetUrl().GetParamBool(constant.RouterEnabled, false) == flag { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
cluster/router/tag/router_rule.go
Outdated
// RouterRule RouterRule config read from config file or config center | ||
type RouterRule struct { | ||
router.BaseRouterRule `yaml:",inline"` | ||
router.BaseRouterRule `yaml:",inline""` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw three " , is this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's old codes on purpose, when delete it will be parsed fail
|
||
// init use for flattening tags data to @addressToTagNames and @tagNameToAddresses | ||
func (t *RouterRule) init() { | ||
t.addressToTagNames = make(map[string][]string, 2*len(t.Tags)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think named init
is golang native. Because init
is golang's special func. Maybe func (t *RouterRule)NewRouterRule is .
cluster/router/tag/tag.go
Outdated
Name string | ||
Addresses []string | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think golang need 'getXXX' .
Codecov Report
@@ Coverage Diff @@
## develop #703 +/- ##
===========================================
- Coverage 63.93% 63.77% -0.16%
===========================================
Files 238 239 +1
Lines 12487 12778 +291
===========================================
+ Hits 7983 8149 +166
- Misses 3740 3833 +93
- Partials 764 796 +32
Continue to review full report at Codecov.
|
cluster/router/tag/tag_router.go
Outdated
// to false, which means it will invoke any providers without a tag unless it's explicitly disallowed. | ||
if len(result) > 0 || isForceUseTag(url, invocation) { | ||
return result | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls delete the else.
What this PR does:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: