spring-cloud/spring-cloud-commons

Add load balancer auto-configuration for `RestClient`

hpoettker opened this issue · 2 comments

Status Quo

The Spring Cloud Load Balancer currently offers auto-configuration for RestTemplate and WebClient.

I assume the LoadBalancerInterceptor and RetryLoadBalancerInterceptor will work with the new RestClient in the same way as with the RestTemplate. But there currently is no auto-configuration for RestClient available.

Feature Request

Add configuration support with annotations like @LoadBalanced for the RestClient.

Thanks for creating the issue, @hpoettker. We're currently working on it.

Hi @OlgaMaciaszek . I see you have added support for the @LoadBalanced annotation and updated the documents.

But I can't find a way how I can use autoconfiguration Builder and @LoadBalanced together.

Due to the use of micrometer tracing and eureka in the project. And if I use autoconfiguration, then only micrometer works, or when I use @LoadBalanced, then all autoconfiguration is disabled and only LB works

I just want to get a stateless constructor with all the autoconfiguration or something like that:

@LoadBalanced
@Bean
public RestClient restClient (RestClient.Builder restClientBuilder)
{
   return restClientBuilder.build();
}

Then the builder will still remain stateless and will be automatically configured. And we got all the autoconfigurations + LB