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 multipleSocketAddress
es select the most desiredSocketAddress
to 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()
APublisher
of 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
- AFunction
that evaluates a connection for selection. This selector should returnnull
if the connection MUST not be selected. This selector is guaranteed to be called for any connection that is returned from this method.- Returns:
- a
Single
that completes with the most appropriate connection to use.
-
eventStream
Publisher<java.lang.Object> eventStream()
APublisher
of events provided by thisLoadBalancer
. This maybe used to broadcast internal state of thisLoadBalancer
to provide hints/visibility for external usage.- Returns:
- A
Publisher
of events provided by thisLoadBalancer
.
-
-