spring-cloud-openfeign
spring-cloud-openfeign copied to clipboard
Make feign.Target.url refreshable
trafficstars
Refer #710
- Created a model class
RefreshableUrlto wrap url. - Created
RefreshableUrlFactoryBeanto create instance ofRefreshableUrlbean with applicable configuration properties. - Created
RefreshableHardCodedTargetto serve url wrapped underRefreshableUrlwhenever needed. urlproperty added toFeignClientProperties#FeignClientConfiguration.FeignClientRegistrar:- created a private method to populate Bean definition for
RefreshableUrlbean. - invoked private method during Feign bean definition registration phase.
- created a private method to populate Bean definition for
FeignClientFactoryBean:- updated to supply
RefreshableHardCodedTargettarget instead ofHardCodedTargetif URL is defined in the propertyspring.cloud.openfeign.client.config.{client-name}.urlandspring.cloud.openfeign.client.refresh-enabled=true.
- updated to supply
- added test cases.
Fixes gh-710.
Codecov Report
Merging #766 (af86e4a) into main (3b02c04) will decrease coverage by
0.28%. The diff coverage is86.00%.
Additional details and impacted files
@@ Coverage Diff @@
## main #766 +/- ##
============================================
- Coverage 79.13% 78.84% -0.29%
- Complexity 548 568 +20
============================================
Files 66 69 +3
Lines 2042 2085 +43
Branches 280 286 +6
============================================
+ Hits 1616 1644 +28
- Misses 265 276 +11
- Partials 161 165 +4
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...amework/cloud/openfeign/FeignClientProperties.java | 87.27% <75.00%> (+0.35%) |
:arrow_up: |
| ...mework/cloud/openfeign/FeignClientFactoryBean.java | 73.83% <77.77%> (-3.36%) |
:arrow_down: |
| ...ork/cloud/openfeign/RefreshableUrlFactoryBean.java | 87.50% <87.50%> (ø) |
|
| ...amework/cloud/openfeign/FeignClientsRegistrar.java | 76.92% <100.00%> (ø) |
|
| ...rk/cloud/openfeign/RefreshableHardCodedTarget.java | 100.00% <100.00%> (ø) |
|
| ...pringframework/cloud/openfeign/RefreshableUrl.java | 100.00% <100.00%> (ø) |
I like this feature
@OlgaMaciaszek implemented logic for URL as per the above discussion.
Thanks a lot @jas34. This PR is nearly ready for merge. I have added some minor issue comments to the documentation changes, but will also request @Buzzardo to review the docs. I have also added one comment regarding the logic. Please discuss the reasoning behind that or modify it.
All comments fixed.