spring-cloud / spring-cloud/spring-cloud-openfeign

Support lb:// url in FeingClient annotation

Open
#489 8 comments 1 reaction 1 assignee View on GitHub

@OlgaMaciaszek is already working on this.

Since Feb 25, 2021.

waiting for votes
Dominant language
Java
Stars
1.3k
Forks
838
Avg merge
2d 11h
Merged PRs (30d)
13

Description

Current behaviour

In a project where is used spring cloud gateway, feign client (with target put in configuration), we ended up having feign clients declared as follows

@FeignClient(name="${service.name:any-name}", url="${service.direct-url:}")

With configuration as follows

service:
   name: service-id
   # url: http://direct-url (only used when service discovery is not available)

This way we are able, by configuration, to either run in service discovery/load balancing mode and direct mode.

Proposal

I kind of like the way spring cloud gateway handle that by allowing lb:// protocol. Allowing this protocol in url attribute would allow the following implementation

@FeignClient(name="technical-name", url="${service.uri}")

with following configuration

service:
   uri: "lb://service-id" # or "http//direct-url"

this way it will let common behaviour, allowing to have a common behaviour in url specification.

I spotted the code responsible for feign client building and think that it would be easily doable by

  • only appending http:// if url attribute value does not match the [a-z]+://.* pattern
  • remove load balancing client if and only if url attribute does not starts with lb://

I am eager to implement it if you allow me to do so. I am also pleased to discuss about it and about any alternative I missed.

Thank you

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.