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

An OpenFeign Client for Dapr Invokes #1294

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

lony2003
Copy link

@lony2003 lony2003 commented Apr 2, 2025

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:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

lony2003 added 6 commits April 1, 2025 21:58
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]>
@lony2003 lony2003 requested review from a team as code owners April 2, 2025 12:53
@salaboy
Copy link
Contributor

salaboy commented Apr 2, 2025

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 ?

public class DaprFeignClientAutoConfiguration {

@Bean
public Targeter targeter(DaprInvokeFeignClient daprInvokeFeignClient) {
Copy link
Author

@lony2003 lony2003 Apr 2, 2025

Choose a reason for hiding this comment

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

The problem is that this bean from Spring Cloud OpenFeign is overrided in this library. I haven't found a solution to make this bean to be @ConditionalOnMissingBean. So is this be allowed in libraries?

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@lony2003 apologies for the delay.. I was at KubeCon last week and I didn't had time to review this.
What's the problem exactly? Can you elaborate a bit? When you run the tests does it clash (is it a duplicate) of another bean?

Copy link
Contributor

Choose a reason for hiding this comment

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

@lony2003 I've triggered the build in CI to check what the problem is.

Copy link
Author

Choose a reason for hiding this comment

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

@salaboy The original Spring Cloud OpenFeign library FeignAutoConfiguration.java#L165C1-L187C1 and FeignAutoConfiguration.java#L204C3-L213C4 there are two Targeter beans used depend on the condition, my Targeter in this library is based on DefaultTargeter, so I was thinking instead of reimplement Targeter, we should use AOP to handle the logic to use DaprFeignClient

Fix the example doc to make openfeign app works in mm.py

Signed-off-by: lony2003 <[email protected]>
@salaboy
Copy link
Contributor

salaboy commented Apr 7, 2025

@lony2003 I've just reviewed this PR and it is looking awesome..
I am currently working on testing multiple sidecars using Testcontainers (for service to service invocation) scenarios, so I will probably tag you in those examples when I have them running. I think this PR is ok (as soon as there are no bean conflicts), then we can create some examples in spring-boot-examples showing the feign clients when we can test service to service invocations with multiple sidecars.

Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 76.69903% with 48 lines in your changes missing coverage. Please review.

Project coverage is 75.46%. Comparing base (d759c53) to head (fd89e6f).
Report is 124 commits behind head on master.

Files with missing lines Patch % Lines
...main/java/io/dapr/feign/DaprInvokeFeignClient.java 74.49% 28 Missing and 10 partials ⚠️
...feign/autoconfigure/DaprFeignClientProperties.java 61.53% 5 Missing ⚠️
.../spring/openfeign/targeter/DaprClientTargeter.java 88.88% 2 Missing ⚠️
...gboot/examples/openfeign/OpenFeignApplication.java 33.33% 2 Missing ⚠️
...a/io/dapr/springboot/examples/openfeign/Order.java 91.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1294      +/-   ##
============================================
- Coverage     76.91%   75.46%   -1.45%     
- Complexity     1592     1660      +68     
============================================
  Files           145      200      +55     
  Lines          4843     5307     +464     
  Branches        562      575      +13     
============================================
+ Hits           3725     4005     +280     
- Misses          821      976     +155     
- Partials        297      326      +29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use With Feign
2 participants