-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
Implement service-level payload #11517
Conversation
Codecov Report
@@ Coverage Diff @@
## 3.2 #11517 +/- ##
============================================
+ Coverage 69.34% 69.39% +0.04%
Complexity 2 2
============================================
Files 1452 1452
Lines 61350 61382 +32
Branches 9056 9060 +4
============================================
+ Hits 42542 42593 +51
+ Misses 14630 14624 -6
+ Partials 4178 4165 -13
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/MetadataInfoTest.java
Outdated
Show resolved
Hide resolved
...i/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java
Show resolved
Hide resolved
dubbo-common/src/main/java/org/apache/dubbo/config/annotation/DubboService.java
Show resolved
Hide resolved
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.
Adding a payload to the request at the communication layer is unnecessary and risky. The verification of the payload is in the following fragment. The payload itself is obtained through the url. We may modify the corresponding value in the current url through filter or other interception.
protected static int getPayload(Channel channel) {
if (channel != null && channel.getUrl() != null) {
return channel.getUrl().getParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD);
}
return Constants.DEFAULT_PAYLOAD;
}
I am thinking about the following:
|
channel.getUrl() The attributes here come from app-config, service-config and other external configurations, so at least they are shared at the service level. @DubboService(parameters = {"payload", "3000"})
public class GameServiceImpl2 implements GameService {
public String play(String name) {
return "hello 2181:" + name;
}
} |
The configuration of parameters parameters may not be obvious to users, so it should be necessary to add attributes to @DubboService |
Thank you very much for your suggestion. It is true that the solution you suggested is the best implementation when the channel is not shared. Consumers share channels through provider address (host + port), each channel holds the url of the service that created it. Therefore, in the sharing mode, it cannot be guaranteed that the payload obtained through the channel is accurate. |
/**
* Get dubbo channel by netty channel through channel cache.
* Put netty channel into it if dubbo channel don't exist in the cache.
*
* @param ch netty channel
* @param url
* @param handler dubbo handler that contain netty's handler
* @return
*/
static NettyChannel getOrAddChannel(Channel ch, URL url, ChannelHandler handler) {
if (ch == null) {
return null;
}
NettyChannel ret = CHANNEL_MAP.get(ch);
if (ret == null) {
NettyChannel nettyChannel = new NettyChannel(ch, url, handler);
if (ch.isActive()) {
nettyChannel.markActive(true);
ret = CHANNEL_MAP.putIfAbsent(ch, nettyChannel);
}
if (ret == null) {
ret = nettyChannel;
}
} else {
ret.markActive(true);
}
return ret;
} @AlbumenJ NettyChannel seems to have a bug here. The key of CHANNEL_MAP is indeed the original channel of netty, and the url is not included, which means that when calling service2, the channel(created by first service) obtained contains the url of service1. The same goes for actual testing. Maybe we can solve it like this: the key of CHANNEL_MAP uses Channel+url instead of Channel |
In this place, cause the url may already be inaccurate. I think Url is used as a property container, and the remoting layer mainly transmits the configuration properties of the remoting layer. Therefore, when dealing with sharing, Url seems to be less important. |
We should prevent to get parameters from channel url. Channel should be shared among services. |
...o-demo-annotation-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
Outdated
Show resolved
Hide resolved
dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/spring/dubbo-provider.xml
Outdated
Show resolved
Hide resolved
@mytang0 Regarding the payload configuration of this service level, is it possible to bind different services to different protocol configs to achieve the purpose? |
Yes, it can be achieved by adding channels, but there is a little violation of channel sharing. |
* mytang0/3.2: (33 commits) Fix conflict Update codecov config (apache#11580) Set timeout value to string (apache#11565) Skip mapping retry if metadata config is invalid (apache#11323) Fix stackoverflow in SerializeSecurityConfigurator (apache#11561) Revert clear response operation of timeoutfilter (apache#11562) Fix hessian2 serializable check (apache#11573) feat: fix oom (apache#11571) Enhance service discovery update interval (apache#11223) Metrics code opt: redundant, modifier, magic (apache#11553) Perfect some code (apache#11533) feat: dubbo provided by (apache#11390) Enhance serializable check option (apache#11460) Fix config absent when refresh (apache#11505) Enhance json util check (apache#11501) Fix the bug in LFUCache#put() method (apache#11538) Bump maven-assembly-plugin from 3.1.0 to 3.4.2 (apache#11547) Bump consul-api from 1.4.2 to 1.4.5 (apache#11545) Bump maven-core from 3.8.7 to 3.9.0 (apache#11546) Bump bytebuddy.version from 1.12.22 to 1.13.0 (apache#11548) ... # Conflicts: # dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvoker.java
PTAL @chickenlj |
* origin/3.2: (32 commits) dubbo-security Jackson error (apache#11622) sync meter to spring boot management (apache#11630) Rest bugfix & optimization (apache#11617) Observability task: metadata center (apache#11593) Enhance the way to get dubbo version (apache#11574) Bump protobuf-java from 3.21.12 to 3.22.0 (apache#11615) Bump maven-surefire-plugin from 3.0.0-M8 to 3.0.0-M9 (apache#11613) Bump micrometer-bom from 1.10.3 to 1.10.4 (apache#11611) Bump libthrift from 0.17.0 to 0.18.0 (apache#11614) Bump maven-failsafe-plugin from 3.0.0-M8 to 3.0.0-M9 (apache#11612) Bump reactor-core from 3.5.2 to 3.5.3 (apache#11610) Bump byte-buddy from 1.13.0 to 1.14.0 (apache#11609) Bump maven-javadoc-plugin from 3.4.1 to 3.5.0 (apache#11608) Bump micrometer-tracing-bom from 1.0.1 to 1.0.2 (apache#11607) 3.2 consumer proxy invocation handler (apache#11108) Update DubboReference.java (apache#11621) Bump version to 3.1.8-SNAPSHOT Add Consumer Metrics (apache#11542) Backport of remove apache-rat-plugin. (apache#11523) (apache#11592) Update codecov config (apache#11582) ...
Kudos, SonarCloud Quality Gate passed! |
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.
What is the purpose of the change
Implement service-level payload. Issue #10773
Brief changelog
Verifying this change
Checklist
Make sure there is a GitHub_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
Each commit in the pull request should have a meaningful subject line and body.
Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
Add some description to dubbo-website project if you are requesting to add a feature.
GitHub Actions works fine on your own branch.
If this contribution is large, please follow the Software Donation Guide.