-
Notifications
You must be signed in to change notification settings - Fork 26.3k
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
Add arguments router to ConditionRouter #7378
Add arguments router to ConditionRouter #7378
Conversation
dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/ConditionRouter.java
Outdated
Show resolved
Hide resolved
dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/condition/ConditionRouter.java
Outdated
Show resolved
Hide resolved
2. param support all type which implements toString. 3. add UT
* Examples would be like this: | ||
* "arguments[0]=1", whenCondition is that the first argument is equal to '1'. | ||
* "arguments[1].param=a", whenCondition is that the 'param' attribute in the second argument is equal to 'a'. | ||
* "arguments[2].inner.param=b", whenCondition is that the 'param' attribute in the 'inner' attribute of the third argument is equal to 'b'. |
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 think it's a good complement to have an argument matcher.
I think it's better if we can make the argument routing rules simpler while still covering more than 90% of the usage scenarios.
For example, we only support the matching of string type parameters and do not support t matching of complex objects like arguments[1].param
. Or even our routing rule is like a switch, when the user tells us to turn it on, we will constantly match the first parameter of the method and require that this parameter be a string or primitive type.
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 think it's a good complement to have an argument matcher.
I think it's better if we can make the argument routing rules simpler while still covering more than 90% of the usage scenarios.
For example, we only support the matching of string type parameters and do not support t matching of complex objects like
arguments[1].param
. Or even our routing rule is like a switch, when the user tells us to turn it on, we will constantly match the first parameter of the method and require that this parameter be a string or primitive type.
I would like to simplify the arguments rule to make it easier to be understood and used.
For example, we only support "one flour param", like "arguments[0]=1", and only support java primary data type, like int, long, string and so on.
But I think it is not a good idea to make it like a switch, that would reduce flexibility.
And in the future, I would like to config arguments router in the configuration pages, we could use drop-down box to choose the right arguments and its value. And in that time, we could expand the explementation of arguments router.
@AlbumenJ
…e "arguments[0]=1". 2. to make it easier to use, the value only support java primary data type.
Codecov Report
@@ Coverage Diff @@
## master #7378 +/- ##
============================================
- Coverage 58.72% 58.68% -0.05%
- Complexity 425 493 +68
============================================
Files 1043 1076 +33
Lines 42471 43439 +968
Branches 6212 6344 +132
============================================
+ Hits 24942 25492 +550
- Misses 14748 15111 +363
- Partials 2781 2836 +55 Continue to review full report at Codecov.
|
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.
LGTM.
Add arguments router logic to ConditionRouter.
What is the purpose of the change
Add arguments router to ConditionRouter.
Compatible to current ConditionRouter logic.
Brief changelog
Add arguments router to ConditionRouter
Verifying this change
Add arguments router to ConditionRouter
Examples
In some cases, we need to choose the right provider while the arguments of the method is setted.
The condition rule is like
While the str property of the second argument is equal to b, the providers whose host is equal to 1.1.1.1 are to be choosed。
We could use this feature to route requests according to business params.
The feature is compatible to current ConditionRouter logic.
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX
. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false
&mvn clean test-compile failsafe:integration-test
to make sure unit-test and integration-test pass.