Skip to content

Support Multiple Clients Using The Same Service #90

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

Merged
merged 6 commits into from
Jan 7, 2019
Merged

Support Multiple Clients Using The Same Service #90

merged 6 commits into from
Jan 7, 2019

Conversation

Ph0ndragX
Copy link
Contributor

Fixes gh-67

Verified

This commit was signed with the committer’s verified signature.
Fixes gh-67
@codecov-io
Copy link

codecov-io commented Dec 4, 2018

Codecov Report

Merging #90 into master will decrease coverage by 0.1%.
The diff coverage is 81.81%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #90      +/-   ##
===========================================
- Coverage      76.8%   76.7%   -0.11%     
- Complexity      298     302       +4     
===========================================
  Files            37      37              
  Lines          1246    1262      +16     
  Branches        185     187       +2     
===========================================
+ Hits            957     968      +11     
- Misses          211     216       +5     
  Partials         78      78
Impacted Files Coverage Δ Complexity Δ
...amework/cloud/openfeign/FeignClientsRegistrar.java 83.85% <100%> (+0.79%) 47 <2> (+3) ⬆️
...gframework/cloud/openfeign/FeignClientBuilder.java 92.85% <33.33%> (-7.15%) 2 <0> (ø)
...mework/cloud/openfeign/FeignClientFactoryBean.java 66.45% <75%> (+0.21%) 45 <4> (+1) ⬆️
...bbon/HttpClientFeignLoadBalancedConfiguration.java 90.32% <0%> (-6.46%) 2% <0%> (ø)

@codecov-io
Copy link

Codecov Report

Merging #90 into master will decrease coverage by 0.03%.
The diff coverage is 58.82%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #90      +/-   ##
============================================
- Coverage      76.8%   76.77%   -0.04%     
- Complexity      298      301       +3     
============================================
  Files            37       37              
  Lines          1246     1257      +11     
  Branches        185      187       +2     
============================================
+ Hits            957      965       +8     
- Misses          211      213       +2     
- Partials         78       79       +1
Impacted Files Coverage Δ Complexity Δ
...mework/cloud/openfeign/FeignClientFactoryBean.java 65.85% <50%> (-0.39%) 46 <1> (+2)
...amework/cloud/openfeign/FeignClientsRegistrar.java 83.42% <71.42%> (+0.36%) 45 <2> (+1) ⬆️

Copy link
Contributor

@ryanjbaxter ryanjbaxter left a comment

Choose a reason for hiding this comment

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

How does this relate to #67?

import java.util.Map;
import java.util.Objects;

import feign.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

We dont use * imports. Also the import order is wrong

Verified

This commit was signed with the committer’s verified signature.
@Ph0ndragX
Copy link
Contributor Author

I described what has been done on the issue page

DuplicatedFeignClientNamesConfiguration.BarClient.class})
protected static class DuplicatedFeignClientNamesConfiguration {

@FeignClient(name = "bar", serviceId = "bar")
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a lot of questions, but this example configuration doesnt make any sense to me, how are these different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a typo, fixed it. I wanted to test if it is possible to create two feign clients with the same serviceId, since it was previously used as a name taking precedence over name/value attribute (FeignClientsRegistrar.java#219 before changes). Actually, I was expecting this to fail, but it seems that by default allow bean overriding is set to true.

@ryanjbaxter
Copy link
Contributor

I dont think we can change the use of the serviceId parameter now as it was deprecated, this could break people.

@spencergibb thoughts?

@spencergibb
Copy link
Member

serviceId is deprecated. I don't want to change it.

Copy link
Contributor

@ryanjbaxter ryanjbaxter left a comment

Choose a reason for hiding this comment

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

Can you add some documentation?

@ryanjbaxter ryanjbaxter added enhancement New feature or request and removed for-team-discussion labels Dec 17, 2018
@ryanjbaxter ryanjbaxter changed the title Use serviceId as url target if present. Support Multiple Clients Using The Same Service Dec 17, 2018
Copy link
Member

@spencergibb spencergibb left a comment

Choose a reason for hiding this comment

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

LGTM. This should be documented as another way to have multiple feign clients for the same service or url. The building feign clients by hand should remain in the docs.

@@ -73,6 +73,8 @@ in your external configuration (see

A central concept in Spring Cloud's Feign support is that of the named client. Each feign client is part of an ensemble of components that work together to contact a remote server on demand, and the ensemble has a name that you give it as an application developer using the `@FeignClient` annotation. Spring Cloud creates a new ensemble as an
`ApplicationContext` on demand for each named client using `FeignClientsConfiguration`. This contains (amongst other things) an `feign.Decoder`, a `feign.Encoder`, and a `feign.Contract`.
It is possible to override the name of that ensemble by using the `contextId`
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 an example of what this enables would be useful

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

Successfully merging this pull request may close these issues.

None yet

5 participants