Package io.smallrye.stork.api
Interface LoadBalancer
-
public interface LoadBalancerWorks with a single service name. Provides a single service instance.
Must be non-blocking
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanrequiresStrictRecording()LoadBalancers often record information of the calls being made with instances they return, be it inflight requests, response time, etc.ServiceInstanceselectServiceInstance(Collection<ServiceInstance> serviceInstances)Select a singleServiceInstancefrom the given list.
-
-
-
Method Detail
-
selectServiceInstance
ServiceInstance selectServiceInstance(Collection<ServiceInstance> serviceInstances)
Select a singleServiceInstancefrom the given list.- Parameters:
serviceInstances- instances to choose from- Returns:
- a ServiceInstance
- Throws:
NoServiceInstanceFoundException- if the incoming collection is empty or all the service instances in the collection are deemed invalid for some reason
-
requiresStrictRecording
default boolean requiresStrictRecording()
LoadBalancers often record information of the calls being made with instances they return, be it inflight requests, response time, etc.
These calculations often assume that an operation using a previously selected service instance is marked as started before the next instance selection. This prevents a situation in which multiple parallel invocations of the LoadBalancer return the same service instance (because they have the same input for selection).
If the load balancer is insusceptible of this problem, this method should return false.- Returns:
- true if the selecting service instance should be called atomically with marking the operation as started
- See Also:
Service.selectInstanceAndRecordStart(boolean),Service.selectInstanceAndRecordStart(Collection, boolean)
-
-