spring-cloud-openfeign icon indicating copy to clipboard operation
spring-cloud-openfeign copied to clipboard

Make feign.Target.url refreshable

Open jas34 opened this issue 3 years ago • 1 comments
trafficstars

Refer #710

  • Created a model class RefreshableUrl to wrap url.
  • Created RefreshableUrlFactoryBean to create instance of RefreshableUrl bean with applicable configuration properties.
  • Created RefreshableHardCodedTarget to serve url wrapped under RefreshableUrl whenever needed.
  • url property added to FeignClientProperties#FeignClientConfiguration.
  • FeignClientRegistrar:
    • created a private method to populate Bean definition for RefreshableUrl bean.
    • invoked private method during Feign bean definition registration phase.
  • FeignClientFactoryBean:
    • updated to supply RefreshableHardCodedTarget target instead of HardCodedTarget if URL is defined in the property spring.cloud.openfeign.client.config.{client-name}.url and spring.cloud.openfeign.client.refresh-enabled=true.
  • added test cases.

Fixes gh-710.

jas34 avatar Oct 09 '22 14:10 jas34

Codecov Report

Merging #766 (af86e4a) into main (3b02c04) will decrease coverage by 0.28%. The diff coverage is 86.00%.

Additional details and impacted files

Impacted file tree graph

@@             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%> (ø)

codecov[bot] avatar Oct 09 '22 14:10 codecov[bot]

I like this feature

galaxy-sea avatar Oct 21 '22 01:10 galaxy-sea

@OlgaMaciaszek implemented logic for URL as per the above discussion.

jas34 avatar Oct 23 '22 12:10 jas34

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.

jas34 avatar Oct 25 '22 13:10 jas34