Class RandomLoadBalancer
- java.lang.Object
-
- org.springframework.cloud.loadbalancer.core.RandomLoadBalancer
-
- All Implemented Interfaces:
ReactiveLoadBalancer<ServiceInstance>,ReactorLoadBalancer<ServiceInstance>,ReactorServiceInstanceLoadBalancer
public class RandomLoadBalancer extends Object implements ReactorServiceInstanceLoadBalancer
A random-based implementation ofReactorServiceInstanceLoadBalancer.- Since:
- 2.2.7
- Author:
- Olga Maciaszek-Sharma
-
-
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 RandomLoadBalancer(org.springframework.beans.factory.ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider, String serviceId)
-
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
-
RandomLoadBalancer
public RandomLoadBalancer(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
-
-
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
-
-