Class RoundRobinLoadBalancer
java.lang.Object
org.springframework.cloud.loadbalancer.core.RoundRobinLoadBalancer
- All Implemented Interfaces:
org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer<org.springframework.cloud.client.ServiceInstance>, ReactorLoadBalancer<org.springframework.cloud.client.ServiceInstance>, ReactorServiceInstanceLoadBalancer
A Round-Robin-based implementation of
ReactorServiceInstanceLoadBalancer.- Author:
- Spencer Gibb, Olga Maciaszek-Sharma, Zhuozhi JI, Nan Chiu
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer
org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer.Factory<T> -
Field Summary
Fields inherited from interface org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer
REQUEST -
Constructor Summary
ConstructorsConstructorDescriptionRoundRobinLoadBalancer(org.springframework.beans.factory.ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider, String serviceId) RoundRobinLoadBalancer(org.springframework.beans.factory.ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider, String serviceId, int seedPosition) -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<org.springframework.cloud.client.loadbalancer.Response<org.springframework.cloud.client.ServiceInstance>> choose(org.springframework.cloud.client.loadbalancer.Request request) Choose the next server based on the load balancing algorithm.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ReactorLoadBalancer
choose
-
Constructor Details
-
RoundRobinLoadBalancer
public RoundRobinLoadBalancer(org.springframework.beans.factory.ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider, String serviceId) - Parameters:
serviceInstanceListSupplierProvider- a provider ofServiceInstanceListSupplierthat will be used to get available instancesserviceId- id of the service for which to choose an instance
-
RoundRobinLoadBalancer
public RoundRobinLoadBalancer(org.springframework.beans.factory.ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider, String serviceId, int seedPosition) - Parameters:
serviceInstanceListSupplierProvider- a provider ofServiceInstanceListSupplierthat will be used to get available instancesserviceId- id of the service for which to choose an instanceseedPosition- Round Robin element position marker
-
-
Method Details
-
choose
public reactor.core.publisher.Mono<org.springframework.cloud.client.loadbalancer.Response<org.springframework.cloud.client.ServiceInstance>> choose(org.springframework.cloud.client.loadbalancer.Request request) Description copied from interface:ReactorLoadBalancerChoose the next server based on the load balancing algorithm.- Specified by:
choosein interfaceorg.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer<org.springframework.cloud.client.ServiceInstance>- Specified by:
choosein interfaceReactorLoadBalancer<org.springframework.cloud.client.ServiceInstance>- Parameters:
request- - an input request- Returns:
- - mono of response
-