Skip to content
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

http protocol detector #12452

Merged
merged 10 commits into from
Jun 8, 2023
Merged

http protocol detector #12452

merged 10 commits into from
Jun 8, 2023

Conversation

suncairong163
Copy link
Contributor

What is the purpose of the change

add http protocol detector for support http PortUnification

Brief changelog

Verifying this change

@AlbumenJ

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.

@suncairong163
Copy link
Contributor Author

@chickenlj rest protocol is integrated into PortUnification

@codecov-commenter
Copy link

codecov-commenter commented Jun 4, 2023

Codecov Report

❗ No coverage uploaded for pull request base (3.3@30daba2). Click here to learn what that means.
The diff coverage is n/a.

@@          Coverage Diff           @@
##             3.3   #12452   +/-   ##
======================================
  Coverage       ?   68.28%           
  Complexity     ?        5           
======================================
  Files          ?     1644           
  Lines          ?    67735           
  Branches       ?     9872           
======================================
  Hits           ?    46254           
  Misses         ?    17007           
  Partials       ?     4474           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@AlbumenJ
Copy link
Member

AlbumenJ commented Jun 5, 2023

@EarthChen @CrazyHZM PTAL

/**
* for http methods
*/
public class HttpUtils {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is not suitable for the dubco-common module in terms of function and methods. There is no current intersection between qos and http handling except HttpMethod, and the methods in HttpUtils are not suitable for all modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok , I will change the position

return Result.UNRECOGNIZED;
}

default Result detect(ChannelBuffer in, URL url) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a use for url, and it shouldn't be in this interface definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.qos和rest 在http检测这块是有冲突的, 当Qos 和rest同时开启时, 需要进行 requestUrl 判断 , service经过 RestProtocol 进行export时才认为 rest开启,不能通过RestProtocol的存在与否判断,这个rest开启标志通过url进行传递
2.希望detector添加 开关,通过url属性进行判断
所以就增加了这个参数

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 我在想qos有关http的是不是还是需要依赖http的模块,这样才能保证所有http的实现都在一个地方,它的层级应该跟triple是一样的,应该在抽象的http之上,qos的命令应该只是rest服务接口中的一部分,但是qos命令受开关影响,举个例子,有一个AbstractHttpProtocolDetector。
  2. 这个判断应该是有export的时候就应该把开关传递过来,就像QosEnableFlag,但我觉得这个开关的确可以被抽象在ProtocolDetector中。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AbstractHttpProtocolDetector 这个抽象可以的有qos和http两个实现,ProtocolDetector 直接进行enable的set,因为QosWireProtocol 这个是单例的,不同url之间开关会不会有影响?增加url参数也是想动态的进行开关,还有就是如果用户想显式的关闭某种协议就不能单单通过export判断了

*/
public interface ProtocolDetector {
int empty = ' ';

default Result detect(ChannelBuffer in) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to change this to default.

Copy link
Member

@CrazyHZM CrazyHZM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…tocol_detector

# Conflicts:
#	dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/pu/QosDetector.java
#	dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/pu/QosHTTP1Detector.java
#	dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/api/ProtocolDetector.java
#	dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyConfigOperator.java
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 11 Code Smells

42.9% 42.9% Coverage
0.0% 0.0% Duplication

@CrazyHZM CrazyHZM merged commit 85bc6ea into apache:3.3 Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants