Class RoundRobinLoadBalancer
- java.lang.Object
-
- org.springframework.cloud.loadbalancer.core.RoundRobinLoadBalancer
-
- All Implemented Interfaces:
ReactiveLoadBalancer<ServiceInstance>,ReactorLoadBalancer<ServiceInstance>,ReactorServiceInstanceLoadBalancer
public class RoundRobinLoadBalancer extends Object implements ReactorServiceInstanceLoadBalancer
A Round-Robin-based implementation ofReactorServiceInstanceLoadBalancer.- Author:
- Spencer Gibb, Olga Maciaszek-Sharma, Zhuozhi JI
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer
ReactiveLoadBalancer.Factory<T extends Object>
-
-
Field Summary
-
Fields inherited from interface org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer
REQUEST
-
-
Constructor Summary
Constructors Constructor Description RoundRobinLoadBalancer(org.springframework.beans.factory.ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider, String serviceId)RoundRobinLoadBalancer(org.springframework.beans.factory.ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider, String serviceId, int seedPosition)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description reactor.core.publisher.Mono<Response<ServiceInstance>>choose(Request request)Choose the next server based on the load balancing algorithm.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer
choose
-
-
-
-
Constructor Detail
-
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 Detail
-
choose
public reactor.core.publisher.Mono<Response<ServiceInstance>> choose(Request request)
Description copied from interface:ReactorLoadBalancerChoose the next server based on the load balancing algorithm.- Specified by:
choosein interfaceReactiveLoadBalancer<ServiceInstance>- Specified by:
choosein interfaceReactorLoadBalancer<ServiceInstance>- Parameters:
request- - an input request- Returns:
- - mono of response
-
-