-
Notifications
You must be signed in to change notification settings - Fork 218
An OpenFeign Client for Dapr Invokes #1294
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: master
Are you sure you want to change the base?
Conversation
A OpenFeign Client and it's AutoConfiguration using Dapr Invoke APIs. Splited into two librarys, dapr-openfeign-client is the pure client of OpenFeign, and dapr-spring-openfeign is the plugin of Spring Cloud OpenFeign. Currently only HTTP Invoke Method and Invoke Binding supported, and Invoke Binding is not always recommend to use this client, depends on what binding component is. Signed-off-by: lony2003 <[email protected]>
A OpenFeign Client and it's AutoConfiguration using Dapr Invoke APIs. Splited into two librarys, dapr-openfeign-client is the pure client of OpenFeign, and dapr-spring-openfeign is the plugin of Spring Cloud OpenFeign. Currently only HTTP Invoke Method and Invoke Binding supported, and Invoke Binding is not always recommend to use this client, depends on what binding component is. Signed-off-by: lony2003 <[email protected]>
A OpenFeign Client and it's AutoConfiguration using Dapr Invoke APIs. Splited into two librarys, dapr-openfeign-client is the pure client of OpenFeign, and dapr-spring-openfeign is the plugin of Spring Cloud OpenFeign. Currently only HTTP Invoke Method and Invoke Binding supported, and Invoke Binding is not always recommend to use this client, depends on what binding component is. Signed-off-by: lony2003 <[email protected]>
this example can redirect order request to producer-app. It needs producer-app to run properly. Signed-off-by: lony2003 <[email protected]>
this test tests the PostgreSQL binding of dapr. Signed-off-by: lony2003 <[email protected]>
Signed-off-by: lony2003 <[email protected]>
I haven't reviewed this yet @lony2003 , but I am more convinced that we need this .. @artur-ciocanu @mcruzdev can you help me to check this PR ? |
...n/src/main/java/io/dapr/spring/openfeign/autoconfigure/DaprFeignClientAutoConfiguration.java
Outdated
Show resolved
Hide resolved
Fix the example doc to make openfeign app works in mm.py Signed-off-by: lony2003 <[email protected]>
@lony2003 I've just reviewed this PR and it is looking awesome.. |
…riginal Targeter beans instead of override them. Signed-off-by: lony2003 <[email protected]>
@salaboy I have changed the |
...gn-app/src/main/java/io/dapr/springboot/examples/openfeign/ProducerClientRestController.java
Show resolved
Hide resolved
Signed-off-by: lony2003 <[email protected]>
…ingMessagingIT works Signed-off-by: lony2003 <[email protected]>
…oot 3.3.x Signed-off-by: lony2003 <[email protected]>
…gIT works Signed-off-by: lony2003 <[email protected]>
@cicoyle I have checked all files and add headers for them, and I have solved the problem that makes IT failed. Please re-trigger the CI. |
Hey @lony2003 - thanks, before I can retrigger CI it says there are conflicts needing to be resolved. Mind resolving them locally and pushing? Then we'll be able to proceed 🙏🏻 |
Signed-off-by: lony2003 <[email protected]>
8580167
to
a330ef2
Compare
…R_RUNTIME_IMAGE_TAG Signed-off-by: lony2003 <[email protected]>
6d1e70a
to
1767276
Compare
3eaa83e
to
c381e44
Compare
… client bean autowired Job SDK ITs have a daprPreviewClient bean defined, as SpringBoot bean search will first get beans that impl the interface and get all beans that matches the bean's class, when openfeign autowire DaprClient, there is a conflict between daprClient and daprPreviewClient. Change the AutoConfiguration behavior to make a more strict rule for making AutoConfiguration run Signed-off-by: lony2003 <[email protected]>
00fae6b
to
bc6d98c
Compare
… client bean autowired Job SDK ITs have a daprPreviewClient bean defined, as SpringBoot bean search will first get beans that impl the interface and get all beans that matches the bean's class, when openfeign autowire DaprClient, there is a conflict between daprClient and daprPreviewClient. Change the AutoConfiguration behavior to make a more strict rule for making AutoConfiguration run Signed-off-by: lony2003 <[email protected]>
change APP_PORT to 8082 Signed-off-by: lony2003 <[email protected]>
@cicoyle conflict solved. |
@lony2003 I am happy to see the CI happy for this PR, can you check the codecov? |
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.
LGTM
@dapr/maintainers-java-sdk I believe that we can merge this PR, we will incrementally improve the quality of this PR, but I want this module to be present in the SDK. Please approve, we can fix any findings in smaller PRs. |
I really want this merged too, but I am not a maintainer |
@Ds2994 are you using this integration already in your project ? |
Yes @salaboy I am currently using this in an internal project and having a lot of readability trouble with the overloaded methods in DaprClient. If this declarative approach gets merged will make a lot of my development cleaner. |
@artur-ciocanu @cicoyle do you have any more concerns on this one ? I think this still need to be rebased by @lony2003 |
Signed-off-by: lony2003 <[email protected]>
Signed-off-by: lony2003 <[email protected]>
6addcf4
to
3b9b9d4
Compare
@salaboy @artur-ciocanu @cicoyle I have merged the latest base for this PR. |
@dapr/maintainers-java-sdk please lets merge this when you can. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1294 +/- ##
============================================
+ Coverage 76.91% 77.86% +0.95%
- Complexity 1592 1888 +296
============================================
Files 145 235 +90
Lines 4843 5933 +1090
Branches 562 622 +60
============================================
+ Hits 3725 4620 +895
- Misses 821 982 +161
- Partials 297 331 +34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
waiting on CI to ensure a 🟢 run 👍🏻 |
@cicoyle CI have passed. Could you please merge it? |
@salaboy @cicoyle @artur-ciocanu is there any problem remains? It'a simple patch, so I think it's easier to review than cloud config. Could you please merge it before a breaking change happened? |
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.
@lony2003 thanks a lot for your contribution. I see the value of this PR and will be a great addition to Dapr Spring portfolio.
I have left quite a few comments. Please take a look and let me know your thoughts.
A few thing that I want to highlight:
- I don't think OpenFeign makes a lot of sense outside Spring ecosystem, so having a dedicated module named "dapr-openfeign-client" is not really required and I would move it to "dapr-spring-openfeign"
- Using "UseDaprClient" annotation I would argue that a more ergonomic approach is to have a single annotation named "DaprFeignClient" that looks like "FeignClient" but leverages DaprClient behind the scenes.
- In the PR we have Feign and OpenFeign in classes, properties file and artifacts. We should have a single naming approach. Since this is part of Spring Cloud we should probably have names like:
dapr.spring.cloud.openfeign.client....
- for propertiesio.dapr.spring.cloud.openfeign...
- for package namesDaprOpenFeign...
- for class names
This way we can have a more consistent naming scheme.
<dependencies> | ||
<dependency> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>feign-core</artifactId> |
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.
Please move version to parent POM, so we can control all the upgrades from a single place.
</dependency> | ||
<dependency> | ||
<groupId>io.github.openfeign</groupId> | ||
<artifactId>feign-jaxrs</artifactId> |
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.
Please move version to parent POM. This is a test dependency, so it should be moved closer to other test dependencies.
We try to keep prod dependencies first, followed by test dependencies.
</dependency> | ||
</dependencies> | ||
|
||
</project> |
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.
Please add new line.
@@ -0,0 +1,11 @@ | |||
<FindBugsFilter> |
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 you please provide more details, why we need these exclusions and why we can't fix the code so we don't need these exclusions.
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
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 package is artifact is named dapr-openfeign-client
, I think it is a good idea to be consistent and name the package: io.dapr.openfeign
"description": "retries for invoke fails." | ||
} | ||
] | ||
} |
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.
Add new line
@@ -0,0 +1 @@ | |||
io.dapr.spring.openfeign.autoconfigure.DaprFeignClientAutoConfiguration |
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.
Add new line
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
|
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.
From a design perspective wouldn't it be better to have a composite annotation like:
@DaprFeignClient(name = "invoke-binding", url = "http://binding.democlient/")
Instead of always using two annotations like:
FeignClient(name = "invoke-binding", url = "http://binding.democlient/")
@UseDaprClient
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.
Actually, FeignClient annotation is from Spring Cloud Openfeign, and I think this two annotation means that this interface is a FeignClient and it uses DaprClient to send RPC requests. So I would say it's not a good idea to have a composite annotation.
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.
And I should say that we use Spring Cloud Openfeign is for it's automatic features in application and IDE, and a composite annotation will definitely break these features, at least in IDE, features provided by Spring Boot plugin would not available while using a DaprFeignClient
@@ -0,0 +1 @@ | |||
dapr.feign.enabled=true |
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.
As I mentioned let's use dapr.openfeign.client
@@ -8,4 +8,9 @@ | |||
<Package name="~io\.dapr\.spring.*"/> | |||
<Bug pattern="EI_EXPOSE_REP2"/> | |||
</Match> | |||
|
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 you please make sure to fix the code and remove this exclusion
@artur-ciocanu about dapr-openfeign-client, I think since Openfeign is developed by OpenFeign Community, and is actively developing while Spring Cloud Openfeign is inactived, there should be other usage besides Spring Cloud Openfeign. So I think it's a good idea to have separate library as there should be some users who don't use SpringBoot but uses OpenFeign. |
I agree with @lony2003 , this would feel like using spring cloud open feign, it doesn't need to expose any Dapr specific interface or annotation |
Description
A OpenFeign Client and it's AutoConfiguration using Dapr Invoke APIs.
Splited into two librarys, dapr-openfeign-client is the pure client of OpenFeign, and dapr-spring-openfeign is the plugin of Spring Cloud OpenFeign.
Currently only HTTP Invoke Method and Invoke Binding supported, and Invoke Binding is not always recommend to use this client, depends on what binding component is.
Issue reference
this PR will close: #1181
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: