Support lb:// url in FeingClient annotation

Đang mở
#489 8 bình luận 1 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@OlgaMaciaszek đang làm issue này rồi.

Từ ngày 25/2/2021.

  • #518 của @antechrestos — đã đóng, không merge

Đánh giá

Issue này chưa được đánh giá.

Mô tả

waiting for votes

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

Ngôn ngữ chính
Java
Star
1.3k
Fork
834
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của spring-cloud/spring-cloud-openfeign

Tất cả issue của spring-cloud/spring-cloud-openfeign

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.