Package io.servicetalk.client.api
Interface LoadBalancerFactory<ResolvedAddress,C extends LoadBalancedConnection>
- Type Parameters:
ResolvedAddress
- The type of address after resolution.C
- The type of connection.
- All Superinterfaces:
ExecutionStrategyInfluencer<ExecutionStrategy>
- All Known Subinterfaces:
HttpLoadBalancerFactory<ResolvedAddress>
- All Known Implementing Classes:
CacheConnectionHttpLoadBalanceFactory
,DefaultHttpLoadBalancerFactory
,DefaultHttpLoadBalancerFactory
,RoundRobinLoadBalancerFactory
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface LoadBalancerFactory<ResolvedAddress,C extends LoadBalancedConnection>
extends ExecutionStrategyInfluencer<ExecutionStrategy>
A factory for creating
LoadBalancer
instances.-
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends C>
LoadBalancer<T>newLoadBalancer
(Publisher<? extends ServiceDiscovererEvent<ResolvedAddress>> eventPublisher, ConnectionFactory<ResolvedAddress, T> connectionFactory) Deprecated.default LoadBalancer<C>
newLoadBalancer
(Publisher<? extends Collection<? extends ServiceDiscovererEvent<ResolvedAddress>>> eventPublisher, ConnectionFactory<ResolvedAddress, C> connectionFactory, String targetResource) Create a newLoadBalancer
.<T extends C>
LoadBalancer<T>newLoadBalancer
(String targetResource, Publisher<? extends Collection<? extends ServiceDiscovererEvent<ResolvedAddress>>> eventPublisher, ConnectionFactory<ResolvedAddress, T> connectionFactory) Deprecated.default ExecutionStrategy
Return anExecutionStrategy
that describes the offloads required by the influencer.
-
Method Details
-
newLoadBalancer
@Deprecated default <T extends C> LoadBalancer<T> newLoadBalancer(Publisher<? extends ServiceDiscovererEvent<ResolvedAddress>> eventPublisher, ConnectionFactory<ResolvedAddress, T> connectionFactory) Deprecated.Create a newLoadBalancer
.- Type Parameters:
T
- Type of connections created by the passedConnectionFactory
.- Parameters:
eventPublisher
- A stream ofServiceDiscovererEvent
s which theLoadBalancer
can use to connect to physical hosts. Typically generated from aServiceDiscoverer
.connectionFactory
-ConnectionFactory
that the returnedLoadBalancer
will use to generate new connections. ReturnedLoadBalancer
will own the responsibility for thisConnectionFactory
and hence will callAsyncCloseable.closeAsync()
whenAsyncCloseable.closeAsync()
is called.- Returns:
- a new
LoadBalancer
.
-
newLoadBalancer
@Deprecated <T extends C> LoadBalancer<T> newLoadBalancer(String targetResource, Publisher<? extends Collection<? extends ServiceDiscovererEvent<ResolvedAddress>>> eventPublisher, ConnectionFactory<ResolvedAddress, T> connectionFactory) Deprecated.Create a newLoadBalancer
.- Type Parameters:
T
- Type of connections created by the passedConnectionFactory
.- Parameters:
targetResource
- AString
representation of the target resource for which the created instance will perform load balancing. Bear in mind, load balancing is performed over the a collection of hosts provided via theeventPublisher
which may not correspond directly to a single unresolved address, but potentially a merged collection.eventPublisher
- A stream ofCollection
<ServiceDiscovererEvent
> which theLoadBalancer
can use to connect to physical hosts. Typically generated fromServiceDiscoverer
.connectionFactory
-ConnectionFactory
that the returnedLoadBalancer
will use to generate new connections. ReturnedLoadBalancer
will own the responsibility for thisConnectionFactory
and hence will callAsyncCloseable.closeAsync()
whenAsyncCloseable.closeAsync()
is called.- Returns:
- a new
LoadBalancer
.
-
newLoadBalancer
default LoadBalancer<C> newLoadBalancer(Publisher<? extends Collection<? extends ServiceDiscovererEvent<ResolvedAddress>>> eventPublisher, ConnectionFactory<ResolvedAddress, C> connectionFactory, String targetResource) Create a newLoadBalancer
.- Parameters:
eventPublisher
- A stream ofCollection
<ServiceDiscovererEvent
> which theLoadBalancer
can use to connect to physical hosts. Typically generated fromServiceDiscoverer
.connectionFactory
-ConnectionFactory
that the returnedLoadBalancer
will use to generate new connections. ReturnedLoadBalancer
will own the responsibility for thisConnectionFactory
and hence will callAsyncCloseable.closeAsync()
whenAsyncCloseable.closeAsync()
is called.targetResource
- AString
representation of the target resource for which the created instance will perform load balancing. Bear in mind, load balancing is performed over the collection of hosts provided via theeventPublisher
which may not correspond directly to a single unresolved address, but potentially a merged collection.- Returns:
- a new
LoadBalancer
.
-
requiredOffloads
Description copied from interface:ExecutionStrategyInfluencer
Return anExecutionStrategy
that describes the offloads required by the influencer.- Specified by:
requiredOffloads
in interfaceExecutionStrategyInfluencer<ResolvedAddress>
- Returns:
- the
ExecutionStrategy
required by the influencer.
-
newLoadBalancer(Publisher, ConnectionFactory, String)
.