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
-
Field Summary
Fields inherited from class DelegatingServiceInstanceListSupplier
delegate -
Constructor Summary
ConstructorsConstructorDescriptionHealthCheckServiceInstanceListSupplier(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 Summary
Modifier and TypeMethodDescriptionvoidvoiddestroy()reactor.core.publisher.Flux<List<org.springframework.cloud.client.ServiceInstance>> get()protected reactor.core.publisher.Flux<List<org.springframework.cloud.client.ServiceInstance>> healthCheckFlux(List<org.springframework.cloud.client.ServiceInstance> instances) protected reactor.core.publisher.Mono<Boolean> isAlive(org.springframework.cloud.client.ServiceInstance serviceInstance) Methods inherited from class DelegatingServiceInstanceListSupplier
getDelegate, getServiceId, selectedServiceInstanceMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ServiceInstanceListSupplier
get
-
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:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Overrides:
afterPropertiesSetin classDelegatingServiceInstanceListSupplier
-
healthCheckFlux
-
get
-
isAlive
protected reactor.core.publisher.Mono<Boolean> isAlive(org.springframework.cloud.client.ServiceInstance serviceInstance) -
destroy
public void destroy()- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Overrides:
destroyin classDelegatingServiceInstanceListSupplier
-