spring-cloud / spring-cloud-commons

Common classes used in different Spring Cloud implementations
Apache License 2.0
704 stars 700 forks source link

Add load balancer auto-configuration for `RestClient` #1293

Closed hpoettker closed 10 months ago

hpoettker commented 10 months ago

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.

OlgaMaciaszek commented 10 months ago

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

EvilGeniusRoll commented 2 months ago

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