-
Notifications
You must be signed in to change notification settings - Fork 8.9k
feature : Integrate Raft and Protocol Switching Based on Server Version #7586
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
base: 2.x
Are you sure you want to change the base?
Changes from 13 commits
1bff80d
48a14a5
6d5ee7d
43066d6
ba7eb0a
b6eee18
433b1b7
698a629
727c1ce
5bdfc01
223d9b9
6f69b97
5518d7f
d98da93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,9 +35,9 @@ | |
| import java.util.Map; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| public class Http5ClientUtil { | ||
| public class Http2ClientUtil { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we name it HttpClientUtil? It handles more than just HTTP/2 requests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a factory class can be provided, for example, called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, recently I have been thinking about one point: whether the http2 function is supported or not not only depends on the business system's reliance on jar packages, but also on whether the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At first, what I considered was abstraction through an So for now, I also think a factory class is the best option. However, unifying the APIs of the two utility classes seems difficult at this point due to differences in their internal logic. It might be a good idea to revisit this after you finish the work on #7561. |
||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(Http5ClientUtil.class); | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(Http2ClientUtil.class); | ||
|
|
||
| private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); | ||
|
|
||
|
|
@@ -50,7 +50,7 @@ public class Http5ClientUtil { | |
| public static final MediaType MEDIA_TYPE_JSON = MediaType.parse("application/json"); | ||
| public static final MediaType MEDIA_TYPE_FORM_URLENCODED = MediaType.parse("application/x-www-form-urlencoded"); | ||
|
|
||
| public static void doPostHttp( | ||
| public static void doPost( | ||
| String url, Map<String, String> params, Map<String, String> headers, HttpCallback<Response> callback) { | ||
| try { | ||
| Headers.Builder headerBuilder = new Headers.Builder(); | ||
|
|
@@ -75,8 +75,7 @@ public static void doPostHttp( | |
| } | ||
| } | ||
|
|
||
| public static void doPostHttp( | ||
| String url, String body, Map<String, String> headers, HttpCallback<Response> callback) { | ||
| public static void doPost(String url, String body, Map<String, String> headers, HttpCallback<Response> callback) { | ||
| Headers.Builder headerBuilder = new Headers.Builder(); | ||
| if (headers != null) { | ||
| headers.forEach(headerBuilder::add); | ||
|
|
@@ -93,7 +92,7 @@ public static void doPostHttp( | |
| executeAsync(HTTP_CLIENT, request, callback); | ||
| } | ||
|
|
||
| public static void doGetHttp( | ||
| public static void doGet( | ||
| String url, Map<String, String> headers, final HttpCallback<Response> callback, int timeout) { | ||
| OkHttpClient client = new OkHttpClient.Builder() | ||
| .connectTimeout(timeout, TimeUnit.SECONDS) | ||
|
|
||
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.
Could we use the Version class to compare versions instead?