-
Notifications
You must be signed in to change notification settings - Fork 8.9k
refactor:add the dependency probing logic of http and unify the apis of http1 and http2 #7684
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
Open
YvCeung
wants to merge
36
commits into
apache:2.x
Choose a base branch
from
YvCeung:xiaoyu1009
base: 2.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+940
−695
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
2dafe93
init structure
YvCeung dd105cd
unify api
YvCeung 9996b4e
modify http1 api
YvCeung 10410e7
refactor clusterControllerTest
YvCeung 70f08c4
Compatible with historical code
d42e3cd
unify http2 api
3a6bbbc
optimize code format
YvCeung 2e880b4
optimize unit test case
YvCeung 208a2ab
optimize http2 unit test case
YvCeung 1625bfe
modify test case
YvCeung f3113a9
fix ut case
YvCeung 0dc5686
format code
YvCeung ae8efe4
fix some ut case
YvCeung 5b91c51
fix some ut case
YvCeung eadde63
Merge branch '2.x' into xiaoyu1009
YvCeung 67a4ffc
optimize code
YvCeung f8af053
format code
YvCeung 63d2189
fix error ut case
YvCeung 7ade817
optimize code
YvCeung a54b947
optimize code
YvCeung 8ecb132
Remove duplicate apis
YvCeung 5b791f4
Supplement the implementation logic of the api
YvCeung 01e44d1
Simplify the api of http2
YvCeung fb2efb4
format code
YvCeung 7037727
add ut case
YvCeung 2a39bde
add changes
YvCeung e15b3af
remove chinese doc
YvCeung 6089844
Merge branch '2.x' into xiaoyu1009
YvCeung 0777d6d
modify url build case
YvCeung 3bb5013
Merge remote-tracking branch 'origin/xiaoyu1009' into xiaoyu1009
YvCeung 93b77c0
Merge branch '2.x' into xiaoyu1009
YvCeung 9ca1711
Merge branch '2.x' into xiaoyu1009
YvCeung 568b7f0
Merge branch '2.x' into xiaoyu1009
YvCeung faf7c33
Merge branch '2.x' into xiaoyu1009
YvCeung 5d94e4c
Merge remote-tracking branch 'origin/xiaoyu1009' into xiaoyu1009
YvCeung 6ff77b4
fix compile error
YvCeung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why does this instance need to be a singleton?
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 some resources may need to be reused here, such as the connection pool here, and using a singleton can avoid the state inconsistency problems caused by multiple instances and the performance problems caused by frequent object creation.
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.
HTTP_CLIENT_MAP
is already managed as astatic final
field.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.
当我们希望通过 HTTP/2 发起请求时,不仅需要检测客户端是否支持,还必须确认 Seata Server 端 是否具备 HTTP/2 能力。
如果直接使用抽象类提供的通用 API 发起调用,可能会出现这样的问题:客户端最终使用了 HTTP/2 实现类,但服务端并不支持,从而导致不可预期的异常。原因在于当前的依赖检测逻辑中,尚未包含对 Server 端协议版本 的校验。
因此,为了保证在某些场景下能够安全运行,我暂时为每个实现类单独保留了 getInstance() 方法,便于手动选择合适的实现。
待后续在依赖探测中集成 “Server 端 HTTP/2 支持判断” 能力后,这些单例获取方法就可以被移除。届时,所有 HTTP 请求都可统一通过
HttpExecutorFactory.getInstance()
进行调用。This logic serves as a transitional solution.
When we intend to initiate requests over HTTP/2, we must verify not only the client’s capability but also whether the Seata Server supports HTTP/2.
If we directly invoke the generic API provided by the abstract class, it’s possible that the actual implementation used on the client side is based on HTTP/2 while the server does not support it. This could lead to unpredictable exceptions, since the current dependency check mechanism does not include validation for the server-side protocol version.
To ensure stability under such conditions, each implementation class temporarily provides its own getInstance() method, allowing manual selection of the proper executor.
Once the capability detection logic is enhanced to determine whether the server supports HTTP/2, these per-class singleton access methods can be safely removed. At that point, all HTTP requests can be uniformly initiated via
HttpExecutorFactory.getInstance()
.