From 590af029ab75e80c403da3bff056bcb5bf098ab8 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Mon, 12 Aug 2019 09:41:29 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- reference/html/index.html | 119 ++++++++++++++++++++++- reference/html/spring-cloud-commons.html | 119 ++++++++++++++++++++++- 2 files changed, 234 insertions(+), 4 deletions(-) diff --git a/reference/html/index.html b/reference/html/index.html index 97f4ee6e..cfc2a512 100644 --- a/reference/html/index.html +++ b/reference/html/index.html @@ -735,7 +735,7 @@ See

Spring WebClient as a Load Balancer Client

-

WebClient can be automatically configured to use the LoadBalancerClient. +

WebClient can be automatically configured to use a load-balancer client. To create a load-balanced WebClient, create a WebClient.Builder @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@@ -765,6 +765,40 @@ public class MyClass {

The URI needs to use a virtual host name (that is, a service name, not a host name). The Ribbon client is used to create a full physical address.

+
+ + + + + +
+ + +If you want to use a @LoadBalanced WebClient.Builder, you need to have a loadbalancer +implementation in the classpath. It is recommended that you add the +org.springframework.cloud:spring-cloud-loadbalancer dependency to your project. +Then, ReactiveLoadBalancer will be used underneath. +Alternatively, this functionality will also work with spring-cloud-starter-netflix-ribbon, but the request +will be handled by a non-reactive LoadBalancerClient under the hood. Additionally, +spring-cloud-starter-netflix-ribbon is already in maintenance mode, so we do not recommned +adding it to new projects. +
+
+
+ + + + + +
+ + +The ReactorLoadBalancer used underneath supports caching. If cacheManager is detected, +cached version of ServiceInstanceSupplier will be used. If not, we will retrieve instances +from discovery service without caching them. We recommend enabling caching in your project +if you use ReactiveLoadBalancer. +
+

Retrying Failed Requests

@@ -915,8 +949,45 @@ If you see errors such as java.lang.IllegalArgumentException: Can not set

Spring WebFlux WebClient as a Load Balancer Client

+
+

Spring WebFlux WebClient with Reactive Load Balancer

-

WebClient can be configured to use the LoadBalancerClient. LoadBalancerExchangeFilterFunction is auto-configured if spring-webflux is on the classpath. The following example shows how to configure a WebClient to use load balancer:

+

WebClient can be configured to use the ReactiveLoadBalancer. +If you add org.springframework.cloud:spring-cloud-loadbalancer to your project, + ReactorLoadBalancerExchangeFilterFunction is auto-configured if spring-webflux is on the classpath. +The following example shows how to configure a WebClient to use reactive load balancer under the hood:

+
+
+
+
public class MyClass {
+    @Autowired
+    private ReactorLoadBalancerExchangeFilterFunction lbFunction;
+
+    public Mono<String> doOtherStuff() {
+        return WebClient.builder().baseUrl("http://stores")
+            .filter(lbFunction)
+            .build()
+            .get()
+            .uri("/stores")
+            .retrieve()
+            .bodyToMono(String.class);
+    }
+}
+
+
+
+

The URI needs to use a virtual host name (that is, a service name, not a host name). +The ReactorLoadBalancerClient is used to create a full physical address.

+
+
+
+

Spring WebFlux WebClient with non-reactive Load Balancer Client

+
+

If you you don’t have org.springframework.cloud:spring-cloud-loadbalancer in your project, +but you do have spring-cloud-starter-netflix-ribbon, you can still use WebClient with LoadBalancerClient. LoadBalancerExchangeFilterFunction +will be auto-configured if spring-webflux is on the classpath. Please note, however, that this is +uses a non-reactive client under the hood. +The following example shows how to configure a WebClient to use load balancer:

@@ -940,6 +1011,50 @@ If you see errors such as java.lang.IllegalArgumentException: Can not set

The URI needs to use a virtual host name (that is, a service name, not a host name). The LoadBalancerClient is used to create a full physical address.

+
+

WARN: +This approach is now deprecated. +We suggest you use WebFlux with reactive Load-Balancer +instead.

+
+
+
+

Passing your own Load-Balancer Client configuration

+
+

You can also use the @LoadBalancerClient annotation to pass your own load-balancer client configuration, passing the name of the load-balancer client and the configuration class, like so:

+
+
+
+
@Configuration
+@LoadBalancerClient(value = "stores", configuration = StoresLoadBalancerClientConfiguration.class)
+public class MyConfiguration {
+
+	@Bean
+	@LoadBalanced
+	public WebClient.Builder loadBalancedWebClientBuilder() {
+		return WebClient.builder();
+	}
+}
+
+
+
+

It is also possible to pass together multiple configurations (for more than one load-balancer client) via the @LoadBalancerClients annotation, as shown below:

+
+
+
+
@Configuration
+@LoadBalancerClients({@LoadBalancerClient(value = "stores", configuration = StoresLoadBalancerClientConfiguration.class), @LoadBalancerClient(value = "customers", configuration = CustomersLoadBalancerClientConfiguration.class)})
+public class MyConfiguration {
+
+	@Bean
+	@LoadBalanced
+	public WebClient.Builder loadBalancedWebClientBuilder() {
+		return WebClient.builder();
+	}
+}
+
+
+

Ignore Network Interfaces

diff --git a/reference/html/spring-cloud-commons.html b/reference/html/spring-cloud-commons.html index 97f4ee6e..cfc2a512 100644 --- a/reference/html/spring-cloud-commons.html +++ b/reference/html/spring-cloud-commons.html @@ -735,7 +735,7 @@ See

Spring WebClient as a Load Balancer Client

-

WebClient can be automatically configured to use the LoadBalancerClient. +

WebClient can be automatically configured to use a load-balancer client. To create a load-balanced WebClient, create a WebClient.Builder @Bean and use the @LoadBalanced qualifier, as shown in the following example:

@@ -765,6 +765,40 @@ public class MyClass {

The URI needs to use a virtual host name (that is, a service name, not a host name). The Ribbon client is used to create a full physical address.

+
+ + + + + +
+ + +If you want to use a @LoadBalanced WebClient.Builder, you need to have a loadbalancer +implementation in the classpath. It is recommended that you add the +org.springframework.cloud:spring-cloud-loadbalancer dependency to your project. +Then, ReactiveLoadBalancer will be used underneath. +Alternatively, this functionality will also work with spring-cloud-starter-netflix-ribbon, but the request +will be handled by a non-reactive LoadBalancerClient under the hood. Additionally, +spring-cloud-starter-netflix-ribbon is already in maintenance mode, so we do not recommned +adding it to new projects. +
+
+
+ + + + + +
+ + +The ReactorLoadBalancer used underneath supports caching. If cacheManager is detected, +cached version of ServiceInstanceSupplier will be used. If not, we will retrieve instances +from discovery service without caching them. We recommend enabling caching in your project +if you use ReactiveLoadBalancer. +
+

Retrying Failed Requests

@@ -915,8 +949,45 @@ If you see errors such as java.lang.IllegalArgumentException: Can not set

Spring WebFlux WebClient as a Load Balancer Client

+
+

Spring WebFlux WebClient with Reactive Load Balancer

-

WebClient can be configured to use the LoadBalancerClient. LoadBalancerExchangeFilterFunction is auto-configured if spring-webflux is on the classpath. The following example shows how to configure a WebClient to use load balancer:

+

WebClient can be configured to use the ReactiveLoadBalancer. +If you add org.springframework.cloud:spring-cloud-loadbalancer to your project, + ReactorLoadBalancerExchangeFilterFunction is auto-configured if spring-webflux is on the classpath. +The following example shows how to configure a WebClient to use reactive load balancer under the hood:

+
+
+
+
public class MyClass {
+    @Autowired
+    private ReactorLoadBalancerExchangeFilterFunction lbFunction;
+
+    public Mono<String> doOtherStuff() {
+        return WebClient.builder().baseUrl("http://stores")
+            .filter(lbFunction)
+            .build()
+            .get()
+            .uri("/stores")
+            .retrieve()
+            .bodyToMono(String.class);
+    }
+}
+
+
+
+

The URI needs to use a virtual host name (that is, a service name, not a host name). +The ReactorLoadBalancerClient is used to create a full physical address.

+
+
+
+

Spring WebFlux WebClient with non-reactive Load Balancer Client

+
+

If you you don’t have org.springframework.cloud:spring-cloud-loadbalancer in your project, +but you do have spring-cloud-starter-netflix-ribbon, you can still use WebClient with LoadBalancerClient. LoadBalancerExchangeFilterFunction +will be auto-configured if spring-webflux is on the classpath. Please note, however, that this is +uses a non-reactive client under the hood. +The following example shows how to configure a WebClient to use load balancer:

@@ -940,6 +1011,50 @@ If you see errors such as java.lang.IllegalArgumentException: Can not set

The URI needs to use a virtual host name (that is, a service name, not a host name). The LoadBalancerClient is used to create a full physical address.

+
+

WARN: +This approach is now deprecated. +We suggest you use WebFlux with reactive Load-Balancer +instead.

+
+
+
+

Passing your own Load-Balancer Client configuration

+
+

You can also use the @LoadBalancerClient annotation to pass your own load-balancer client configuration, passing the name of the load-balancer client and the configuration class, like so:

+
+
+
+
@Configuration
+@LoadBalancerClient(value = "stores", configuration = StoresLoadBalancerClientConfiguration.class)
+public class MyConfiguration {
+
+	@Bean
+	@LoadBalanced
+	public WebClient.Builder loadBalancedWebClientBuilder() {
+		return WebClient.builder();
+	}
+}
+
+
+
+

It is also possible to pass together multiple configurations (for more than one load-balancer client) via the @LoadBalancerClients annotation, as shown below:

+
+
+
+
@Configuration
+@LoadBalancerClients({@LoadBalancerClient(value = "stores", configuration = StoresLoadBalancerClientConfiguration.class), @LoadBalancerClient(value = "customers", configuration = CustomersLoadBalancerClientConfiguration.class)})
+public class MyConfiguration {
+
+	@Bean
+	@LoadBalanced
+	public WebClient.Builder loadBalancedWebClientBuilder() {
+		return WebClient.builder();
+	}
+}
+
+
+