Class HealthCheckServiceInstanceListSupplier

java.lang.Object
org.springframework.cloud.loadbalancer.core.DelegatingServiceInstanceListSupplier
org.springframework.cloud.loadbalancer.core.HealthCheckServiceInstanceListSupplier
All Implemented Interfaces:
Supplier<reactor.core.publisher.Flux<List<org.springframework.cloud.client.ServiceInstance>>>, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, SelectedInstanceCallback, ServiceInstanceListSupplier

public class HealthCheckServiceInstanceListSupplier extends DelegatingServiceInstanceListSupplier implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
A ServiceInstanceListSupplier implementation that verifies whether the instances are alive and only returns the healthy one, unless there are none. Uses a user-provided function to ping the health endpoint of the instances.
Since:
2.2.0
Author:
Olga Maciaszek-Sharma, Roman Matiushchenko, Roman Chigvintsev
  • Constructor Details

    • HealthCheckServiceInstanceListSupplier

      public HealthCheckServiceInstanceListSupplier(ServiceInstanceListSupplier delegate, org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer.Factory<org.springframework.cloud.client.ServiceInstance> loadBalancerClientFactory, BiFunction<org.springframework.cloud.client.ServiceInstance, String, reactor.core.publisher.Mono<Boolean>> aliveFunction)
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Overrides:
      afterPropertiesSet in class DelegatingServiceInstanceListSupplier
    • healthCheckFlux

      protected reactor.core.publisher.Flux<List<org.springframework.cloud.client.ServiceInstance>> healthCheckFlux(List<org.springframework.cloud.client.ServiceInstance> instances)
    • get

      public reactor.core.publisher.Flux<List<org.springframework.cloud.client.ServiceInstance>> get()
      Specified by:
      get in interface Supplier<reactor.core.publisher.Flux<List<org.springframework.cloud.client.ServiceInstance>>>
    • isAlive

      protected reactor.core.publisher.Mono<Boolean> isAlive(org.springframework.cloud.client.ServiceInstance serviceInstance)
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean
      Overrides:
      destroy in class DelegatingServiceInstanceListSupplier