-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[ISSUE #3197] NacosRestTemplate enhance #3198
[ISSUE #3197] NacosRestTemplate enhance #3198
Conversation
please help to review this pr, thanks @KomachiSion |
We plan to release 1.3.1. We will stop merge PR before 1.3.1 released except code style PR and block issue PR. I will review PR, if approved, I will merge it after 1.3.1 release. |
* @param requestBase requestBase | ||
* @param httpClientConfig http config | ||
*/ | ||
private static void getConfig(HttpRequestBase requestBase, HttpClientConfig httpClientConfig) { |
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 the method name is not good.
|
||
private final HttpClientRequest httpClientRequest; | ||
|
||
private final Iterator<HttpClientRequestInterceptor> iterator; |
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.
iterator is a abstract name, use interceptors maybe better.
private final Query query; | ||
|
||
private Object body; | ||
|
||
public RequestHttpEntity(Header header, Query query) { | ||
handleHeader(header); | ||
this.query = query; | ||
this.httpClientConfig = null; |
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.
change this constructer as this(null, header, query, null)
?
public RequestHttpEntity(HttpClientConfig httpClientConfig, Header header, Query query) { | ||
handleHeader(header); | ||
this.httpClientConfig = httpClientConfig; | ||
this.query = query; |
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.
change this constructer as this(httpClientConfig, header, query, null)?
} | ||
|
||
public RequestHttpEntity(Header header, Query query, Object body) { | ||
handleHeader(header); | ||
this.query = query; | ||
this.body = body; | ||
this.httpClientConfig = null; |
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.
change this constructer as this(null, header, query, body)?
throws Exception { | ||
if (iterator.hasNext()) { | ||
HttpClientRequestInterceptor nextInterceptor = iterator.next(); | ||
return nextInterceptor.intercept(uri, httpMethod, requestHttpEntity, this); |
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.
the Iterate method is too obscure, I suggest change this method.
I have adjusted the code.please help to review this pr again, thanks @KomachiSion |
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.
Good implementation, we will merge after 1.3.1 released
# Conflicts: # common/src/main/java/com/alibaba/nacos/common/http/client/NacosRestTemplate.java
private HttpClientRequest requestClient() { | ||
if (CollectionUtils.isNotEmpty(interceptors)) { | ||
if (LOGGER.isDebugEnabled()) { | ||
LOGGER.debug("Execute via interceptor"); |
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.
Should we print the interceptor name or class name?
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.
okay
# Conflicts: # common/src/main/java/com/alibaba/nacos/common/http/client/NacosRestTemplate.java
Please do not create a Pull Request without creating an issue first.
What is the purpose of the change
NacosRestTemplate enhance to meet the actual http client use
#3197
Brief changelog
Add some parameter configuration of http client to the request method
Add an interceptor for nacos resttemplate, can add some logic through the interceptor
Verifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.