Skip to content

Commit 2710c82

Browse files
Remove ribbon integration (#691)
* Remove Ribbon-specific configuration. * Remove Ribbon-specific docs. Refactor.
1 parent 8a899f0 commit 2710c82

File tree

18 files changed

+31
-766
lines changed

18 files changed

+31
-766
lines changed

docs/src/main/asciidoc/_configprops.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
|spring.cloud.loadbalancer.health-check.interval | 30s | Interval for rerunning the HealthCheck scheduler.
3535
|spring.cloud.loadbalancer.health-check.path | |
3636
|spring.cloud.loadbalancer.retry.enabled | true |
37-
|spring.cloud.loadbalancer.ribbon.enabled | true | Causes `RibbonLoadBalancerClient` to be used by default.
3837
|spring.cloud.refresh.enabled | true | Enables autoconfiguration for the refresh scope and associated features.
3938
|spring.cloud.refresh.extra-refreshable | true | Additional class names for beans to post process into refresh scope.
4039
|spring.cloud.service-registry.auto-registration.enabled | true | Whether service auto-registration is enabled. Defaults to true.

docs/src/main/asciidoc/spring-cloud-commons.adoc

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -389,18 +389,10 @@ CAUTION: A `RestTemplate` bean is no longer created through auto-configuration.
389389
Individual applications must create it.
390390

391391
The URI needs to use a virtual host name (that is, a service name, not a host name).
392-
The Ribbon client is used to create a full physical address.
393-
See {githubroot}/spring-cloud-netflix/blob/master/spring-cloud-netflix-ribbon/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonAutoConfiguration.java[`RibbonAutoConfiguration`] for the details of how the `RestTemplate` is set up.
392+
The BlockingLoadBalancerClient is used to create a full physical address.
394393

395394
IMPORTANT: To use a load-balanced `RestTemplate`, you need to have a load-balancer implementation in your classpath.
396-
The recommended implementation is `BlockingLoadBalancerClient`.
397395
Add <<spring-cloud-loadbalancer-starter, Spring Cloud LoadBalancer starter>> to your project in order to use it.
398-
The
399-
`RibbonLoadBalancerClient` also can be used, but it's now under maintenance and we do not recommend adding it to new projects.
400-
401-
WARNING: By default, if you have both `RibbonLoadBalancerClient` and `BlockingLoadBalancerClient`, to
402-
preserve backward compatibility, `RibbonLoadBalancerClient` is used.
403-
To override it, you can set the `spring.cloud.loadbalancer.ribbon.enabled` property to `false`.
404396

405397
[[webclinet-loadbalancer-client]]
406398
=== Spring WebClient as a Load Balancer Client
@@ -434,29 +426,19 @@ public class MyClass {
434426
====
435427

436428
The URI needs to use a virtual host name (that is, a service name, not a host name).
437-
The Ribbon client or Spring Cloud LoadBalancer is used to create a full physical address.
429+
The Spring Cloud LoadBalancer is used to create a full physical address.
438430

439431
IMPORTANT: If you want to use a `@LoadBalanced WebClient.Builder`, you need to have a load balancer
440432
implementation in the classpath. We recommend that you add the
441433
<<spring-cloud-loadbalancer-starter, Spring Cloud LoadBalancer starter>> to your project.
442434
Then, `ReactiveLoadBalancer` is used underneath.
443-
Alternatively, this functionality also works with `spring-cloud-starter-netflix-ribbon`, but the request
444-
is handled by a non-reactive `LoadBalancerClient` under the hood. Additionally,
445-
`spring-cloud-starter-netflix-ribbon` is already in maintenance mode, so we do not recommend
446-
adding it to new projects.
447-
If you have both `spring-cloud-starter-loadbalancer` and `spring-cloud-starter-netflix-ribbon`
448-
in your classpath, Ribbon is used by default. To switch to Spring Cloud LoadBalancer,
449-
set the `spring.cloud.loadbalancer.ribbon.enabled` property to `false`.
450435

451436
==== Retrying Failed Requests
452437

453438
A load-balanced `RestTemplate` can be configured to retry failed requests.
454439
By default, this logic is disabled.
455440
You can enable it by adding link:https://github.com/spring-projects/spring-retry[Spring Retry] to your application's classpath.
456-
The load-balanced `RestTemplate` honors some of the Ribbon configuration values related to retrying failed requests.
457-
You can use `client.ribbon.MaxAutoRetries`, `client.ribbon.MaxAutoRetriesNextServer`, and `client.ribbon.OkToRetryOnAllOperations` properties.
458441
If you would like to disable the retry logic with Spring Retry on the classpath, you can set `spring.cloud.loadbalancer.retry.enabled=false`.
459-
See the https://github.com/Netflix/ribbon/wiki/Getting-Started#the-properties-file-sample-clientproperties[Ribbon documentation] for a description of what these properties do.
460442

461443
If you would like to implement a `BackOffPolicy` in your retries, you need to create a bean of type `LoadBalancedRetryFactory` and override the `createBackOffPolicy` method:
462444

@@ -478,8 +460,6 @@ public class MyConfiguration {
478460
----
479461
====
480462

481-
NOTE: `client` in the preceding examples should be replaced with your Ribbon client's name.
482-
483463
If you want to add one or more `RetryListener` implementations to your retry functionality, you need to
484464
create a bean of type `LoadBalancedRetryListenerFactory` and return the `RetryListener` array
485465
you would like to use for a given service, as the following example shows:
@@ -649,16 +629,9 @@ public class MyClass {
649629
The URI needs to use a virtual host name (that is, a service name, not a host name).
650630
The `ReactorLoadBalancer` is used to create a full physical address.
651631

652-
NOTE: By default, if you have `spring-cloud-netflix-ribbon` in your classpath, <<load-balancer-exchange-filter-function,`LoadBalancerExchangeFilterFunction`>>
653-
is used to maintain backward compatibility. To use
654-
`ReactorLoadBalancerExchangeFilterFunction`, set the `spring.cloud.loadbalancer.ribbon.enabled` property
655-
to `false`.
656-
657632
[[load-balancer-exchange-filter-function]]
658633
==== Spring WebFlux `WebClient` with a Non-reactive Load Balancer Client
659634

660-
If you you do not have <<spring-cloud-loadbalancer-starter, Spring Cloud LoadBalancer starter>> in your project
661-
but you do have spring-cloud-starter-netflix-ribbon, you can still use `WebClient` with `LoadBalancerClient`.
662635
If `spring-webflux` is on the classpath, `LoadBalancerExchangeFilterFunction`
663636
is auto-configured. Note, however, that this
664637
uses a non-reactive client under the hood.
@@ -1004,9 +977,6 @@ NOTE: Spring Cloud LoadBalancer starter includes
1004977
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-caching.html[Spring Boot Caching]
1005978
and https://github.com/stoyanr[Evictor].
1006979

1007-
WARNING: If you have both Ribbon and Spring Cloud LoadBalancer int the classpath, in order to maintain backward compatibility, Ribbon-based implementations will be used by default.
1008-
In order to switch to using Spring Cloud LoadBalancer under the hood, make sure you set the property `spring.cloud.loadbalancer.ribbon.enabled` to `false`.
1009-
1010980
[[custom-loadbalancer-configuration]]
1011981
=== Passing Your Own Spring Cloud LoadBalancer Configuration
1012982

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/AsyncLoadBalancerAutoConfiguration.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.springframework.web.client.AsyncRestTemplate;
3131

3232
/**
33-
* Auto-configuration for Ribbon (client-side load balancing).
33+
* Auto-configuration for blocking client-side load balancing.
3434
*
3535
* @author Rob Worsnop
3636
*/
@@ -49,13 +49,10 @@ static class AsyncRestTemplateCustomizerConfig {
4949
@Bean
5050
public SmartInitializingSingleton loadBalancedAsyncRestTemplateInitializer(
5151
final List<AsyncRestTemplateCustomizer> customizers) {
52-
return new SmartInitializingSingleton() {
53-
@Override
54-
public void afterSingletonsInstantiated() {
55-
for (AsyncRestTemplate restTemplate : AsyncRestTemplateCustomizerConfig.this.restTemplates) {
56-
for (AsyncRestTemplateCustomizer customizer : customizers) {
57-
customizer.customize(restTemplate);
58-
}
52+
return () -> {
53+
for (AsyncRestTemplate restTemplate : AsyncRestTemplateCustomizerConfig.this.restTemplates) {
54+
for (AsyncRestTemplateCustomizer customizer : customizers) {
55+
customizer.customize(restTemplate);
5956
}
6057
}
6158
};
@@ -75,14 +72,11 @@ public AsyncLoadBalancerInterceptor asyncLoadBalancerInterceptor(
7572
@Bean
7673
public AsyncRestTemplateCustomizer asyncRestTemplateCustomizer(
7774
final AsyncLoadBalancerInterceptor loadBalancerInterceptor) {
78-
return new AsyncRestTemplateCustomizer() {
79-
@Override
80-
public void customize(AsyncRestTemplate restTemplate) {
81-
List<AsyncClientHttpRequestInterceptor> list = new ArrayList<>(
82-
restTemplate.getInterceptors());
83-
list.add(loadBalancerInterceptor);
84-
restTemplate.setInterceptors(list);
85-
}
75+
return restTemplate -> {
76+
List<AsyncClientHttpRequestInterceptor> list = new ArrayList<>(
77+
restTemplate.getInterceptors());
78+
list.add(loadBalancerInterceptor);
79+
restTemplate.setInterceptors(list);
8680
};
8781
}
8882

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerAutoConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.springframework.web.client.RestTemplate;
3636

3737
/**
38-
* Auto-configuration for Ribbon (client-side load balancing).
38+
* Auto-configuration for blocking (client-side load balancing).
3939
*
4040
* @author Spencer Gibb
4141
* @author Dave Syer
@@ -79,7 +79,7 @@ public LoadBalancerRequestFactory loadBalancerRequestFactory(
7979
static class LoadBalancerInterceptorConfig {
8080

8181
@Bean
82-
public LoadBalancerInterceptor ribbonInterceptor(
82+
public LoadBalancerInterceptor loadBalancerInterceptor(
8383
LoadBalancerClient loadBalancerClient,
8484
LoadBalancerRequestFactory requestFactory) {
8585
return new LoadBalancerInterceptor(loadBalancerClient, requestFactory);
@@ -124,7 +124,7 @@ public static class RetryInterceptorAutoConfiguration {
124124

125125
@Bean
126126
@ConditionalOnMissingBean
127-
public RetryLoadBalancerInterceptor ribbonInterceptor(
127+
public RetryLoadBalancerInterceptor loadBalancerInterceptor(
128128
LoadBalancerClient loadBalancerClient,
129129
LoadBalancerRetryProperties properties,
130130
LoadBalancerRequestFactory requestFactory,

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/LoadBalancerBeanPostProcessorAutoConfiguration.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818

1919
import org.springframework.beans.factory.ObjectProvider;
2020
import org.springframework.beans.factory.config.BeanPostProcessor;
21-
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
2221
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
2322
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
2423
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
25-
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2624
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
2725
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
2826
import org.springframework.context.ApplicationContext;
@@ -57,7 +55,6 @@ public LoadBalancerWebClientBuilderBeanPostProcessor loadBalancerWebClientBuilde
5755
}
5856

5957
@Configuration(proxyBeanMethods = false)
60-
@Conditional(OnNoRibbonDefaultCondition.class)
6158
@ConditionalOnBean(ReactiveLoadBalancer.Factory.class)
6259
protected static class ReactorDeferringLoadBalancerFilterConfig {
6360

@@ -71,22 +68,6 @@ DeferringLoadBalancerExchangeFilterFunction<ReactorLoadBalancerExchangeFilterFun
7168

7269
}
7370

74-
@Configuration(proxyBeanMethods = false)
75-
@ConditionalOnBean(LoadBalancerClient.class)
76-
@AutoConfigureAfter(ReactorDeferringLoadBalancerFilterConfig.class)
77-
@Deprecated
78-
protected static class ReactiveLoadBalancerConfig {
79-
80-
@Bean
81-
@ConditionalOnMissingBean
82-
DeferringLoadBalancerExchangeFilterFunction<LoadBalancerExchangeFilterFunction> deferringLoadBalancerExchangeFilterFunction(
83-
ObjectProvider<LoadBalancerExchangeFilterFunction> exchangeFilterFunctionProvider) {
84-
return new DeferringLoadBalancerExchangeFilterFunction<>(
85-
exchangeFilterFunctionProvider);
86-
}
87-
88-
}
89-
9071
static final class OnAnyLoadBalancerImplementationPresentCondition
9172
extends AnyNestedCondition {
9273

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/LoadBalancerExchangeFilterFunction.java

Lines changed: 0 additions & 81 deletions
This file was deleted.

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/OnNoRibbonDefaultCondition.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/reactive/ReactiveLoadBalancerAutoConfiguration.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)