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

FeignClient Configuration Properties #1942

Merged

Conversation

khannedy
Copy link
Contributor

This pull request is improvement for #1931, so we can configure feign client using configuration properties

@codecov-io
Copy link

codecov-io commented May 13, 2017

Codecov Report

Merging #1942 into master will decrease coverage by 0.13%.
The diff coverage is 67.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1942      +/-   ##
==========================================
- Coverage   76.22%   76.09%   -0.14%     
==========================================
  Files         209      210       +1     
  Lines        6377     6467      +90     
  Branches      794      817      +23     
==========================================
+ Hits         4861     4921      +60     
- Misses       1178     1203      +25     
- Partials      338      343       +5
Impacted Files Coverage Δ
...rk/cloud/netflix/feign/FeignAutoConfiguration.java 57.89% <ø> (ø) ⬆️
...ork/cloud/netflix/feign/FeignClientProperties.java 62.26% <62.26%> (ø)
...rk/cloud/netflix/feign/FeignClientFactoryBean.java 74.56% <73.68%> (-0.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34350cb...b142140. Read the comment docs.

@@ -1020,8 +1020,41 @@ public class FooConfiguration {

This replaces the `SpringMvcContract` with `feign.Contract.Default` and adds a `RequestInterceptor` to the collection of `RequestInterceptor`.

`@FeignClient` also can be configured using configuration properties. If we create both `@Configuration` bean and configuration properties, configuration properties will win. It will override `@Configuration` values.
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure what is right, but my gut tells me that @Configuration beans should override properties.

Copy link
Member

Choose a reason for hiding this comment

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

There is precedent for config wins with ribbon

@@ -120,9 +121,63 @@ public void setApplicationContext(ApplicationContext context) throws BeansExcept
builder.decode404();
}

// configure feign builder from properties if exists
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could clean this code up a big. Maybe have a method that extracts the properties whether from configuration beans or properties and then just sets them in the builder in one spot?

@ConfigurationProperties("feign.client")
public class FeignClientProperties {

private String defaultConfig = "default";
Copy link
Contributor

Choose a reason for hiding this comment

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

im not seeing where this is used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @ryanjbaxter , you can see in FeignClientFactoryBean

FeignClientProperties.FeignClientConfiguration defaultConfig = properties.getConfig().get(properties.getDefaultConfig());
if (defaultConfig != null) {
   configureUsingProperties(defaultConfig, builder);
}

@@ -1020,8 +1020,41 @@ public class FooConfiguration {

This replaces the `SpringMvcContract` with `feign.Contract.Default` and adds a `RequestInterceptor` to the collection of `RequestInterceptor`.

`@FeignClient` also can be configured using configuration properties. If we create both `@Configuration` bean and configuration properties, configuration properties will win. It will override `@Configuration` values.
Copy link
Member

Choose a reason for hiding this comment

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

There is precedent for config wins with ribbon

return applicationContext.getBean(tClass);
} catch (NoSuchBeanDefinitionException e) {
try {
return tClass.cast(tClass.newInstance());
Copy link
Member

Choose a reason for hiding this comment

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

We should be using spring to create beans. You can see how ribbon does this.

@@ -0,0 +1,57 @@
/*
* Copyright 2013-2015 the original author or authors.
Copy link
Member

Choose a reason for hiding this comment

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

2017

@khannedy
Copy link
Contributor Author

hi @ryanjbaxter @spencergibb, please review my changes

// optional values
configureFeign(context, builder);

if (decode404) {
Copy link
Member

Choose a reason for hiding this comment

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

Why exclude decode404 from properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me add decode404 to configuration properties

@spencergibb
Copy link
Member

Targeting the Edgware release this summer, should be merged in the next week or two.

@khannedy
Copy link
Contributor Author

@spencergibb I've already added decode404 to configuration properties


If we create both `@Configuration` bean and configuration properties, configuration properties will win.
It will override `@Configuration` values. But if you want to change the priority to `@Configuration`,
you can change `feign.client.primary` to `false`.
Copy link
Member

Choose a reason for hiding this comment

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

This name is bad and doesn't convey that setting this to false will result in @Configuration winning. Maybe feign.client.default-to-properties?

Copy link
Contributor Author

@khannedy khannedy Jun 8, 2017

Choose a reason for hiding this comment

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

ok, I'll change properties name to default-to-properties

/**
* @author Eko Kurniawan Khannedy
*/
@Data
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove lombok, we're going to move away, it would be helpful to not have to convert this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I'll remove lombok

@khannedy
Copy link
Contributor Author

khannedy commented Jun 8, 2017

@spencergibb please review the changes

@spencergibb spencergibb merged commit c2c6347 into spring-cloud:master Jul 7, 2017
@khannedy khannedy deleted the features/feign_client_properties branch December 4, 2018 14:12
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.

None yet

4 participants