Package io.servicetalk.client.api
Interface LoadBalancer<C extends LoadBalancedConnection>
-
- Type Parameters:
C- The type of connection.
- All Superinterfaces:
AsyncCloseable,ListenableAsyncCloseable
- All Known Implementing Classes:
RoundRobinLoadBalancer
public interface LoadBalancer<C extends LoadBalancedConnection> extends ListenableAsyncCloseable
Given multipleSocketAddresses select the most desiredSocketAddressto use. This is typically used to determine which connection to issue a request to.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Publisher<java.lang.Object>eventStream()APublisherof events provided by thisLoadBalancer.Single<C>selectConnection(java.util.function.Predicate<C> selector)Select the most appropriate connection for a request.-
Methods inherited from interface io.servicetalk.concurrent.api.AsyncCloseable
closeAsync, closeAsyncGracefully
-
Methods inherited from interface io.servicetalk.concurrent.api.ListenableAsyncCloseable
onClose
-
-
-
-
Method Detail
-
selectConnection
Single<C> selectConnection(java.util.function.Predicate<C> selector)
Select the most appropriate connection for a request. Returned connection may be used concurrently for other requests.- Parameters:
selector- AFunctionthat evaluates a connection for selection. This selector should returnnullif the connection MUST not be selected. This selector is guaranteed to be called for any connection that is returned from this method.- Returns:
- a
Singlethat completes with the most appropriate connection to use.
-
eventStream
Publisher<java.lang.Object> eventStream()
APublisherof events provided by thisLoadBalancer. This maybe used to broadcast internal state of thisLoadBalancerto provide hints/visibility for external usage.- Returns:
- A
Publisherof events provided by thisLoadBalancer.
-
-