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

refactor load balance client so that users can add their custom implementation

Open
#777 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Java
Stars
1.3k
Forks
838
Avg merge
2d 11h
Merged PRs (30d)
13

Description

Is your feature request related to a problem? Please describe.

My application needs to add a custom Client like FeignBlockingLoadBalancerClient, e.g.

public class CustomFeignBlockingLoadBalancerClient implements Client {
  ...
}

CustomFeignBlockingLoadBalancerClient will add some extensions to FeignBlockingLoadBalancerClient, like tracing.

This works pretty well when using load-balanced clients. But when mixed with load-balanced and non-load-balanced clients, FeignClientFactoryBean hard coded to work with FeignBlockingLoadBalancerClient to get the delegate

		if (client != null) {
			if (client instanceof FeignBlockingLoadBalancerClient) {
				// not load balancing because we have a url,
				// but Spring Cloud LoadBalancer is on the classpath, so unwrap
				client = ((FeignBlockingLoadBalancerClient) client).getDelegate();
			}
			if (client instanceof RetryableFeignBlockingLoadBalancerClient) {
				// not load balancing because we have a url,
				// but Spring Cloud LoadBalancer is on the classpath, so unwrap
				client = ((RetryableFeignBlockingLoadBalancerClient) client).getDelegate();
			}
			builder.client(client);
		}

see https://github.com/spring-cloud/spring-cloud-openfeign/pull/776

Describe the solution you'd like
see https://github.com/spring-cloud/spring-cloud-openfeign/pull/776

Describe alternatives you've considered
see https://github.com/spring-cloud/spring-cloud-openfeign/pull/776

Additional context
NA

This issue is created for future enhancement to loadbalancer client customization.

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.

Research direction

Start in FeignClientFactoryBean and inspect FeignBlockingLoadBalancerClient and RetryableFeignBlockingLoadBalancerClient, especially their delegate handling. Review the approach described in spring-cloud-openfeign pull request 776. Done means custom Client implementations can add extensions while mixed load-balanced and URL-based clients still select the correct delegate.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.