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 ExecutionStrategyReturn anExecutionStrategythat 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 ofServiceDiscovererEvents which theLoadBalancercan use to connect to physical hosts. Typically generated from aServiceDiscoverer.connectionFactory-ConnectionFactorythat the returnedLoadBalancerwill use to generate new connections. ReturnedLoadBalancerwill own the responsibility for thisConnectionFactoryand 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- AStringrepresentation 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 theeventPublisherwhich may not correspond directly to a single unresolved address, but potentially a merged collection.eventPublisher- A stream ofCollection<ServiceDiscovererEvent> which theLoadBalancercan use to connect to physical hosts. Typically generated fromServiceDiscoverer.connectionFactory-ConnectionFactorythat the returnedLoadBalancerwill use to generate new connections. ReturnedLoadBalancerwill own the responsibility for thisConnectionFactoryand 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 theLoadBalancercan use to connect to physical hosts. Typically generated fromServiceDiscoverer.connectionFactory-ConnectionFactorythat the returnedLoadBalancerwill use to generate new connections. ReturnedLoadBalancerwill own the responsibility for thisConnectionFactoryand hence will callAsyncCloseable.closeAsync()whenAsyncCloseable.closeAsync()is called.targetResource- AStringrepresentation 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 theeventPublisherwhich may not correspond directly to a single unresolved address, but potentially a merged collection.- Returns:
- a new
LoadBalancer.
-
requiredOffloads
Description copied from interface:ExecutionStrategyInfluencerReturn anExecutionStrategythat describes the offloads required by the influencer.- Specified by:
requiredOffloadsin interfaceExecutionStrategyInfluencer<ResolvedAddress>- Returns:
- the
ExecutionStrategyrequired by the influencer.
-
newLoadBalancer(Publisher, ConnectionFactory, String).