From f8665ad8e76365b4f0da21dfd0b19b6ce405ca1b Mon Sep 17 00:00:00 2001 From: buildmaster Date: Tue, 4 Feb 2020 09:26:18 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- reference/html/appendix.html | 20 ++++-- reference/html/index.html | 89 ++++++++++++++++++++++-- reference/html/spring-cloud-commons.html | 89 ++++++++++++++++++++++-- 3 files changed, 181 insertions(+), 17 deletions(-) diff --git a/reference/html/appendix.html b/reference/html/appendix.html index e803138e..7dccf073 100644 --- a/reference/html/appendix.html +++ b/reference/html/appendix.html @@ -280,6 +280,21 @@ Also, you can define your own properties.

Time To Live - time counted from writing of the record, after which cache entries are expired, expressed as a {@link Duration}. The property {@link String} has to be in keeping with the appropriate syntax as specified in Spring Boot <code>StringToDurationConverter</code>. @see <a href= "https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/StringToDurationConverter.java">StringToDurationConverter.java</a>

+

spring.cloud.loadbalancer.health-check.initial-delay

+

0

+

Initial delay value for the HealthCheck scheduler.

+ + +

spring.cloud.loadbalancer.health-check.interval

+

30s

+

Interval for rerunning the HealthCheck scheduler.

+ + +

spring.cloud.loadbalancer.health-check.path

+ + + +

spring.cloud.loadbalancer.retry.enabled

true

@@ -290,11 +305,6 @@ Also, you can define your own properties.

Causes RibbonLoadBalancerClient to be used by default.

-

spring.cloud.loadbalancer.zone

- -

A {@link String} representation of the <code>zone</code> used for filtering instances by zoned load-balancing implementations.

- -

spring.cloud.refresh.enabled

true

Enables autoconfiguration for the refresh scope and associated features.

diff --git a/reference/html/index.html b/reference/html/index.html index 8347c27c..ce595f9c 100644 --- a/reference/html/index.html +++ b/reference/html/index.html @@ -165,8 +165,9 @@ $(addBlockSwitches);
  • 3.3. Zone-Based Load-Balancing
  • -
  • 3.4. Spring Cloud LoadBalancer Starter
  • -
  • 3.5. Passing Your Own Spring Cloud LoadBalancer Configuration
  • +
  • 3.4. Instance Health-Check for LoadBalancer
  • +
  • 3.5. Spring Cloud LoadBalancer Starter
  • +
  • 3.6. Passing Your Own Spring Cloud LoadBalancer Configuration
  • 4. Spring Cloud Circuit Breaker @@ -1564,12 +1565,12 @@ We suggest passing a DiscoveryClientServiceInstanceListSupplier del @Bean public ServiceInstanceListSupplier discoveryClientServiceInstanceListSupplier( ReactiveDiscoveryClient discoveryClient, Environment environment, - LoadBalancerProperties loadBalancerProperties, + LoadBalancerZoneConfig zoneConfig, ApplicationContext context) { DiscoveryClientServiceInstanceListSupplier firstDelegate = new DiscoveryClientServiceInstanceListSupplier( discoveryClient, environment); ZonePreferenceServiceInstanceListSupplier delegate = new ZonePreferenceServiceInstanceListSupplier(firstDelegate, - loadBalancerProperties); + zoneConfig); ObjectProvider<LoadBalancerCacheManager> cacheManagerProvider = context .getBeanProvider(LoadBalancerCacheManager.class); if (cacheManagerProvider.getIfAvailable() != null) { @@ -1583,7 +1584,83 @@ We suggest passing a DiscoveryClientServiceInstanceListSupplier del
    -

    3.4. Spring Cloud LoadBalancer Starter

    +

    3.4. Instance Health-Check for LoadBalancer

    +
    +

    It is possible to enable a scheduled HealthCheck for the LoadBalancer. The HealthCheckServiceInstanceListSupplier +is provided for that. It regularly verifies if the instances provided by a delegate +ServiceInstanceListSupplier are still alive and only returns the healthy instances, +unless there are none - then it returns all the retrieved instances.

    +
    +
    + + + + + +
    + + +This mechanism is particularly helpful while using the SimpleDiscoveryClient. For the +clients backed by an actual Service Registry, it’s not necessary to use, as we already get +healthy instances after querying the external ServiceDiscovery. +
    +
    +
    +

    The HealthCheckServiceInstanceListSupplier uses InstanceHealthChecker to verify if the instances are +alive. We provide a default PingHealthChecker instance. It uses WebClient to execute +requests against the health endpoint of the instance. You can also provide your own implementation +of InstanceHealthChecker instead.

    +
    +
    +

    HealthCheckServiceInstanceListSupplier uses properties prefixed with +spring.cloud.loadbalancer.healthcheck. You can set the initialDelay and interval +for the scheduler.

    +
    +
    +

    For the PingHealthChecker, you can set the default path for the healthcheck URL by setting +the value of the spring.cloud.loadbalancer.healthcheck.path.default. You can also set a specific value +for any given service by setting the value of the spring.cloud.loadbalancer.healthcheck.path.[SERVICE_ID], +substituting the [SERVICE_ID] with the correct ID of your service. If the path is not set, +/actuator/health is used by default.

    +
    +
    +

    In order to use the health-check scheduler approach, you will have to instantiate a HealthCheckServiceInstanceListSupplier bean in a custom configuration.

    +
    +
    +

    We use delegates to work with ServiceInstanceListSupplier beans. +We suggest passing a DiscoveryClientServiceInstanceListSupplier delegate in the constructor of HealthCheckServiceInstanceListSupplier and, in turn, wrapping the latter with a CachingServiceInstanceListSupplier to leverage LoadBalancer caching mechanism.

    +
    +
    +

    You could use this sample configuration to set it up:

    +
    +
    +
    +
    public class CustomLoadBalancerConfiguration {
    +
    +    @Bean
    +    public ServiceInstanceListSupplier discoveryClientServiceInstanceListSupplier(
    +            ReactiveDiscoveryClient discoveryClient, Environment environment,
    +            LoadBalancerProperties loadBalancerProperties,
    +            ApplicationContext context,
    +            InstanceHealthChecker healthChecker) {
    +        DiscoveryClientServiceInstanceListSupplier firstDelegate = new DiscoveryClientServiceInstanceListSupplier(
    +                discoveryClient, environment);
    +        HealthCheckServiceInstanceListSupplier delegate = new HealthCheckServiceInstanceListSupplier(firstDelegate,
    +                loadBalancerProperties, healthChecker);
    +        ObjectProvider<LoadBalancerCacheManager> cacheManagerProvider = context
    +                .getBeanProvider(LoadBalancerCacheManager.class);
    +        if (cacheManagerProvider.getIfAvailable() != null) {
    +            return new CachingServiceInstanceListSupplier(delegate,
    +                    cacheManagerProvider.getIfAvailable());
    +        }
    +        return delegate;
    +    }
    +    }
    +
    +
    +
    +
    +

    3.5. Spring Cloud LoadBalancer Starter

    We also provide a starter that allows you to easily add Spring Cloud LoadBalancer in a Spring Boot app. In order to use it, just add org.springframework.cloud:spring-cloud-starter-loadbalancer to your Spring Cloud dependencies in your build file.

    @@ -1617,7 +1694,7 @@ In order to switch to using Spring Cloud LoadBalancer under the hood, make sure
    -

    3.5. Passing Your Own Spring Cloud LoadBalancer Configuration

    +

    3.6. Passing Your Own Spring Cloud LoadBalancer 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, as follows:

    diff --git a/reference/html/spring-cloud-commons.html b/reference/html/spring-cloud-commons.html index 8347c27c..ce595f9c 100644 --- a/reference/html/spring-cloud-commons.html +++ b/reference/html/spring-cloud-commons.html @@ -165,8 +165,9 @@ $(addBlockSwitches);
  • 3.3. Zone-Based Load-Balancing
  • -
  • 3.4. Spring Cloud LoadBalancer Starter
  • -
  • 3.5. Passing Your Own Spring Cloud LoadBalancer Configuration
  • +
  • 3.4. Instance Health-Check for LoadBalancer
  • +
  • 3.5. Spring Cloud LoadBalancer Starter
  • +
  • 3.6. Passing Your Own Spring Cloud LoadBalancer Configuration
  • 4. Spring Cloud Circuit Breaker @@ -1564,12 +1565,12 @@ We suggest passing a DiscoveryClientServiceInstanceListSupplier del @Bean public ServiceInstanceListSupplier discoveryClientServiceInstanceListSupplier( ReactiveDiscoveryClient discoveryClient, Environment environment, - LoadBalancerProperties loadBalancerProperties, + LoadBalancerZoneConfig zoneConfig, ApplicationContext context) { DiscoveryClientServiceInstanceListSupplier firstDelegate = new DiscoveryClientServiceInstanceListSupplier( discoveryClient, environment); ZonePreferenceServiceInstanceListSupplier delegate = new ZonePreferenceServiceInstanceListSupplier(firstDelegate, - loadBalancerProperties); + zoneConfig); ObjectProvider<LoadBalancerCacheManager> cacheManagerProvider = context .getBeanProvider(LoadBalancerCacheManager.class); if (cacheManagerProvider.getIfAvailable() != null) { @@ -1583,7 +1584,83 @@ We suggest passing a DiscoveryClientServiceInstanceListSupplier del
    -

    3.4. Spring Cloud LoadBalancer Starter

    +

    3.4. Instance Health-Check for LoadBalancer

    +
    +

    It is possible to enable a scheduled HealthCheck for the LoadBalancer. The HealthCheckServiceInstanceListSupplier +is provided for that. It regularly verifies if the instances provided by a delegate +ServiceInstanceListSupplier are still alive and only returns the healthy instances, +unless there are none - then it returns all the retrieved instances.

    +
    +
    + + + + + +
    + + +This mechanism is particularly helpful while using the SimpleDiscoveryClient. For the +clients backed by an actual Service Registry, it’s not necessary to use, as we already get +healthy instances after querying the external ServiceDiscovery. +
    +
    +
    +

    The HealthCheckServiceInstanceListSupplier uses InstanceHealthChecker to verify if the instances are +alive. We provide a default PingHealthChecker instance. It uses WebClient to execute +requests against the health endpoint of the instance. You can also provide your own implementation +of InstanceHealthChecker instead.

    +
    +
    +

    HealthCheckServiceInstanceListSupplier uses properties prefixed with +spring.cloud.loadbalancer.healthcheck. You can set the initialDelay and interval +for the scheduler.

    +
    +
    +

    For the PingHealthChecker, you can set the default path for the healthcheck URL by setting +the value of the spring.cloud.loadbalancer.healthcheck.path.default. You can also set a specific value +for any given service by setting the value of the spring.cloud.loadbalancer.healthcheck.path.[SERVICE_ID], +substituting the [SERVICE_ID] with the correct ID of your service. If the path is not set, +/actuator/health is used by default.

    +
    +
    +

    In order to use the health-check scheduler approach, you will have to instantiate a HealthCheckServiceInstanceListSupplier bean in a custom configuration.

    +
    +
    +

    We use delegates to work with ServiceInstanceListSupplier beans. +We suggest passing a DiscoveryClientServiceInstanceListSupplier delegate in the constructor of HealthCheckServiceInstanceListSupplier and, in turn, wrapping the latter with a CachingServiceInstanceListSupplier to leverage LoadBalancer caching mechanism.

    +
    +
    +

    You could use this sample configuration to set it up:

    +
    +
    +
    +
    public class CustomLoadBalancerConfiguration {
    +
    +    @Bean
    +    public ServiceInstanceListSupplier discoveryClientServiceInstanceListSupplier(
    +            ReactiveDiscoveryClient discoveryClient, Environment environment,
    +            LoadBalancerProperties loadBalancerProperties,
    +            ApplicationContext context,
    +            InstanceHealthChecker healthChecker) {
    +        DiscoveryClientServiceInstanceListSupplier firstDelegate = new DiscoveryClientServiceInstanceListSupplier(
    +                discoveryClient, environment);
    +        HealthCheckServiceInstanceListSupplier delegate = new HealthCheckServiceInstanceListSupplier(firstDelegate,
    +                loadBalancerProperties, healthChecker);
    +        ObjectProvider<LoadBalancerCacheManager> cacheManagerProvider = context
    +                .getBeanProvider(LoadBalancerCacheManager.class);
    +        if (cacheManagerProvider.getIfAvailable() != null) {
    +            return new CachingServiceInstanceListSupplier(delegate,
    +                    cacheManagerProvider.getIfAvailable());
    +        }
    +        return delegate;
    +    }
    +    }
    +
    +
    +
    +
    +

    3.5. Spring Cloud LoadBalancer Starter

    We also provide a starter that allows you to easily add Spring Cloud LoadBalancer in a Spring Boot app. In order to use it, just add org.springframework.cloud:spring-cloud-starter-loadbalancer to your Spring Cloud dependencies in your build file.

    @@ -1617,7 +1694,7 @@ In order to switch to using Spring Cloud LoadBalancer under the hood, make sure
    -

    3.5. Passing Your Own Spring Cloud LoadBalancer Configuration

    +

    3.6. Passing Your Own Spring Cloud LoadBalancer 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, as follows: