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

[ISSUE #3197] NacosRestTemplate enhance #3198

Merged
merged 12 commits into from
Jul 13, 2020
Merged

[ISSUE #3197] NacosRestTemplate enhance #3198

merged 12 commits into from
Jul 13, 2020

Conversation

Maijh97
Copy link
Collaborator

@Maijh97 Maijh97 commented Jun 29, 2020

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:

  • Make sure there is a Github issue filed 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.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. 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.
  • 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 integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

@Maijh97 Maijh97 changed the title NacosRestTemplate enhance [ISSUE #3197] NacosRestTemplate enhance Jun 29, 2020
@Maijh97
Copy link
Collaborator Author

Maijh97 commented Jun 29, 2020

please help to review this pr, thanks @KomachiSion

@KomachiSion
Copy link
Collaborator

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) {
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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);
Copy link
Collaborator

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.

@Maijh97
Copy link
Collaborator Author

Maijh97 commented Jun 29, 2020

I have adjusted the code.please help to review this pr again, thanks @KomachiSion

@Maijh97 Maijh97 requested a review from KomachiSion June 29, 2020 07:49
KomachiSion
KomachiSion previously approved these changes Jun 30, 2020
Copy link
Collaborator

@KomachiSion KomachiSion left a 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

@KomachiSion KomachiSion added pending On hold due to dependency or release area/Nacos Core kind/refactor labels Jun 30, 2020
@KomachiSion KomachiSion added this to the 1.3.2 milestone Jun 30, 2020
@KomachiSion KomachiSion linked an issue Jun 30, 2020 that may be closed by this pull request
private HttpClientRequest requestClient() {
if (CollectionUtils.isNotEmpty(interceptors)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Execute via interceptor");
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay

@KomachiSion KomachiSion removed the pending On hold due to dependency or release label Jul 13, 2020
# Conflicts:
#	common/src/main/java/com/alibaba/nacos/common/http/client/NacosRestTemplate.java
@KomachiSion KomachiSion merged commit c1515b6 into alibaba:develop Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NacosRestTemplate enhance to meet the actual http client use
2 participants