feat: add Apache HttpClient 5.x adapter support#3613
Closed
uuuyuqi wants to merge 2 commits intoalibaba:masterfrom
Closed
feat: add Apache HttpClient 5.x adapter support#3613uuuyuqi wants to merge 2 commits intoalibaba:masterfrom
uuuyuqi wants to merge 2 commits intoalibaba:masterfrom
Conversation
Add sentinel-apache-httpclient5-adapter module to support flow control for Apache HttpClient 5.x outgoing HTTP requests. The adapter implements ExecChainHandler to intercept requests in the HttpClient exec chain. Key features: - SentinelApacheHttpClient5Handler: ExecChainHandler implementation - Default resource name format: METHOD:url (query/fragment stripped) - Pluggable resource extractor and fallback interfaces - Comprehensive unit and integration tests Change-Id: I6be84c73078102a92c5701cce9f66e1c543f32f7 Co-developed-by: Cursor <noreply@cursor.com>
…L XSS alert Change-Id: Idadec9e77dbebc0d64dee5bd873b4c47b42f4048 Co-developed-by: Cursor <noreply@cursor.com>
Collaborator
Author
|
Closing this PR as it was incorrectly based on master (2.0.0-alpha2-SNAPSHOT). Re-submitting against the bump-version-1.8.10-snapshot branch. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Describe what this PR does / why we need it
Add a new
sentinel-apache-httpclient5-adaptermodule to support flow control for outgoing HTTP requests made with Apache HttpClient 5.x.Apache HttpClient 5.x has been the recommended version since 2020, and 4.x is now in maintenance mode. This PR adds first-class support for the 5.x API.
Does this pull request fix one issue?
Fixes #3612
Describe how you did it
Module structure (
sentinel-adapter/sentinel-apache-httpclient5-adapter):SentinelApacheHttpClient5Handler— ImplementsExecChainHandlerto intercept outgoing requests in the HttpClient 5.x exec chain. UsesSphU.entry()for Sentinel resource entry withEntryType.OUT.SentinelApacheHttpClientConfig— Configuration class with pluggable prefix, resource extractor, and fallback.ApacheHttpClientResourceExtractor/DefaultApacheHttpClientResourceExtractor— Resource name extraction. Default format:METHOD:urlwith query string and fragment stripped (consistent with the existing OkHttp adapter).ApacheHttpClientFallback/DefaultApacheHttpClientFallback— Fallback on block. Default throwsSentinelRpcException.Key design decisions:
ExecChainHandlerinterface — the idiomatic HttpClient 5.x interception mechanism, replacing thedecorateMainExecapproach used in the 4.x adapter.METHOD:url— consistent with the existingsentinel-okhttp-adapterconvention, and auto-strips query/fragment for stable resource keys.Describe how to verify it
mvn compile -pl sentinel-adapter/sentinel-apache-httpclient5-adapter -ammvn test -pl sentinel-adapter/sentinel-apache-httpclient5-adapterUsage example:
Special notes for reviews
ApacheHttpClientResourceExtractor,ApacheHttpClientFallback) follow the same pattern as the existing 4.x adapter and OkHttp adapter.DefaultApacheHttpClientResourceExtractorusesrequest.getUri().toString()which returns the full URL in the exec chain context. Query parameters and fragments are stripped for stable resource naming.providedscope — users bring their own version (5.1+).Made with Cursor