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

Async feign flow #511

Open
wants to merge 6 commits into
base: 2.2.x
Choose a base branch
from
Open

Conversation

thanhj
Copy link
Contributor

@thanhj thanhj commented Mar 13, 2021

No description provided.

@codecov
Copy link

codecov bot commented Mar 13, 2021

Codecov Report

Merging #511 (d585597) into 2.2.x (e3439f3) will increase coverage by 0.53%.
The diff coverage is 81.25%.

Impacted file tree graph

@@             Coverage Diff              @@
##              2.2.x     #511      +/-   ##
============================================
+ Coverage     77.69%   78.22%   +0.53%     
- Complexity      521      560      +39     
============================================
  Files            71       74       +3     
  Lines          2089     2301     +212     
  Branches        290      319      +29     
============================================
+ Hits           1623     1800     +177     
- Misses          327      348      +21     
- Partials        139      153      +14     
Impacted Files Coverage Δ Complexity Δ
...mework/cloud/openfeign/FeignClientFactoryBean.java 71.09% <71.55%> (+2.32%) 88.00 <27.00> (+26.00)
...eign/async/AsyncHttpClient5FeignConfiguration.java 88.33% <88.33%> (ø) 7.00 <7.00> (?)
...d/openfeign/support/FeignHttpClientProperties.java 93.81% <94.73%> (+0.06%) 20.00 <2.00> (+2.00)
...ork/cloud/openfeign/FeignClientsConfiguration.java 95.34% <100.00%> (+0.11%) 17.00 <1.00> (+1.00)
...amework/cloud/openfeign/FeignClientsRegistrar.java 78.92% <100.00%> (+0.20%) 54.00 <0.00> (ø)
...d/openfeign/async/AsyncFeignAutoConfiguration.java 100.00% <100.00%> (ø) 1.00 <1.00> (?)
...rk/cloud/openfeign/async/DefaultAsyncTargeter.java 100.00% <100.00%> (ø) 2.00 <2.00> (?)

@thanhj thanhj changed the title Async feign flow 2.2.x Async feign flow Mar 14, 2021
@thanhj
Copy link
Contributor Author

thanhj commented Mar 22, 2021

Hi @OlgaMaciaszek, any chance that you have checked this PR?

@OlgaMaciaszek
Copy link
Collaborator

Hi, @thanhj - will work on it now.

Copy link
Collaborator

@OlgaMaciaszek OlgaMaciaszek left a comment

Choose a reason for hiding this comment

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

Hello, @thanhj thanks for submitting the PR. Have added some comments regarding things that will need to be changed in order to go forward with it, however, we should probably hold on with it still, as I have noticed that AsyncFeign is still marked as @Experimental and I am not sure we will want to add support till that changes - discussing it with the team.

@@ -166,6 +190,36 @@ protected void configureFeign(FeignContext context, Feign.Builder builder) {
}
}

protected void configureFeign(FeignContext context, AsyncBuilder builder) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The class practically duplicates entire methods, with only small differences. Please refactor it so that this does not happen. You could extract code to smaller methods, use a wrapping interface that could have Builder or AsyncBuilder delegate, or use a method with more general arguments and use instanced checks and casting to process the two types, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is true that there are many duplications, I will try to make it better.

import org.springframework.context.annotation.Configuration;

/**
* @author Nguyen Ky Thanh
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add description to javadoc.

}
}

private TlsStrategy clientTlsStrategy(boolean isDisableSslValidation) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some of the code is similar to what is used by the synchronous version. Could you think of a way of reusing the code instead of duplicating?

import org.springframework.cloud.openfeign.FeignContext;

/**
* @author Nguyen Ky Thanh
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add description to javadoc.

import org.springframework.cloud.openfeign.FeignContext;

/**
* @author Nguyen Ky Thanh
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add description to javadoc.

/**
* Enumeration of pooled connection re-use policies.
*/
public enum PoolReusePolicy {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We cannot remove public types that have already been released in a non-major release. For example, if we released with org.springframework.cloud.openfeign.support.FeignHttpClientProperties.Hc5Properties.PoolReusePolicy, we can reuse it or add a new type, but we cannot just remove it (by placing it as an inner type of a different class).

@thanhj
Copy link
Contributor Author

thanhj commented Apr 15, 2021

Hello, @thanhj thanks for submitting the PR. Have added some comments regarding things that will need to be changed in order to go forward with it, however, we should probably hold on with it still, as I have noticed that AsyncFeign is still marked as @Experimental and I am not sure we will want to add support till that changes - discussing it with the team.

Yes, it is true. But I still hope to receive positive feedback from your team discussion. I believe the @Experimental is more about the class design, and I also have tested the performance of this approach and got it applied to our production.

@OlgaMaciaszek
Copy link
Collaborator

@thanhj we have just discussed it in the team. We've decided that we would not be merging it to the main SC OpenFeign repo until it's @Experimental in Feign. However, we do have an incubator org: https://github.com/spring-cloud-incubator, and we could add a separate plug-in module (would have to be a separate maven dependency) with just the AsyncFeign support there. As an example you can see, https://github.com/spring-cloud-incubator/spring-cloud-sleuth-otel that is an incubator module for a released project (https://github.com/spring-cloud/spring-cloud-sleuth). Please let me know if you would like to work on sth like this.

Copy link
Contributor Author

@thanhj thanhj left a comment

Choose a reason for hiding this comment

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

Yes, I would like to. Please let me know how to contribute there. @olegz

@OlgaMaciaszek
Copy link
Collaborator

@thanhj I have created an incubator repo: https://github.com/spring-cloud-incubator/spring-cloud-openfeign-async and already set it up. Please create a PR with your changes. Please add the changes in the spring-cloud-openfeign-async-core module and use the org.springframework.cloud.openfeign.async.core package.

@thanhj
Copy link
Contributor Author

thanhj commented Apr 26, 2021

Thanks @OlgaMaciaszek, I am on it.

@thanhj
Copy link
Contributor Author

thanhj commented May 2, 2021

I am not very familiar with setting up a Spring library from scratch like this, so it may take me a bit more time to raise first PR.
Also, any suggestion or direction from you would be great, thanks.

@OlgaMaciaszek
Copy link
Collaborator

@thanhj Will give it some thought and get back to you with some guidelines.

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.

None yet

3 participants