Package io.servicetalk.http.api
Class DefaultHttpLoadBalancerFactory<ResolvedAddress>
java.lang.Object
io.servicetalk.http.api.DefaultHttpLoadBalancerFactory<ResolvedAddress>
- Type Parameters:
ResolvedAddress- The type of address after resolution.
- All Implemented Interfaces:
LoadBalancerFactory<ResolvedAddress,,FilterableStreamingHttpLoadBalancedConnection> HttpLoadBalancerFactory<ResolvedAddress>,ExecutionStrategyInfluencer<ExecutionStrategy>
public final class DefaultHttpLoadBalancerFactory<ResolvedAddress>
extends Object
implements HttpLoadBalancerFactory<ResolvedAddress>
Default implementation of
HttpLoadBalancerFactory.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultHttpLoadBalancerFactory(LoadBalancerFactory<ResolvedAddress, FilterableStreamingHttpLoadBalancedConnection> rawFactory) Creates a new instance with execution strategy adapted from the underlying factory. -
Method Summary
Modifier and TypeMethodDescriptionnewLoadBalancer(Publisher<? extends Collection<? extends ServiceDiscovererEvent<ResolvedAddress>>> eventPublisher, ConnectionFactory<ResolvedAddress, FilterableStreamingHttpLoadBalancedConnection> connectionFactory, String targetResource) Create a newLoadBalancer.<T extends FilterableStreamingHttpLoadBalancedConnection>
LoadBalancer<T>newLoadBalancer(String targetResource, Publisher<? extends Collection<? extends ServiceDiscovererEvent<ResolvedAddress>>> eventPublisher, ConnectionFactory<ResolvedAddress, T> connectionFactory) Create a newLoadBalancer.Return anExecutionStrategythat describes the offloads required by the influencer.Converts the passedFilterableStreamingHttpConnectionto aFilterableStreamingHttpLoadBalancedConnection.toLoadBalancedConnection(FilterableStreamingHttpConnection connection, ReservableRequestConcurrencyController concurrencyController, ContextMap context) Converts the passedFilterableStreamingHttpConnectionto aFilterableStreamingHttpLoadBalancedConnection.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.servicetalk.client.api.LoadBalancerFactory
newLoadBalancer
-
Constructor Details
-
DefaultHttpLoadBalancerFactory
public DefaultHttpLoadBalancerFactory(LoadBalancerFactory<ResolvedAddress, FilterableStreamingHttpLoadBalancedConnection> rawFactory) Creates a new instance with execution strategy adapted from the underlying factory.- Parameters:
rawFactory-LoadBalancerFactoryto use
-
-
Method Details
-
newLoadBalancer
public <T extends FilterableStreamingHttpLoadBalancedConnection> LoadBalancer<T> newLoadBalancer(String targetResource, Publisher<? extends Collection<? extends ServiceDiscovererEvent<ResolvedAddress>>> eventPublisher, ConnectionFactory<ResolvedAddress, T> connectionFactory) Description copied from interface:LoadBalancerFactoryCreate a newLoadBalancer.- Specified by:
newLoadBalancerin interfaceLoadBalancerFactory<ResolvedAddress,FilterableStreamingHttpLoadBalancedConnection> - 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
public LoadBalancer<FilterableStreamingHttpLoadBalancedConnection> newLoadBalancer(Publisher<? extends Collection<? extends ServiceDiscovererEvent<ResolvedAddress>>> eventPublisher, ConnectionFactory<ResolvedAddress, FilterableStreamingHttpLoadBalancedConnection> connectionFactory, String targetResource) Description copied from interface:LoadBalancerFactoryCreate a newLoadBalancer.- Specified by:
newLoadBalancerin interfaceLoadBalancerFactory<ResolvedAddress,FilterableStreamingHttpLoadBalancedConnection> - 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.
-
toLoadBalancedConnection
public FilterableStreamingHttpLoadBalancedConnection toLoadBalancedConnection(FilterableStreamingHttpConnection connection) Description copied from interface:HttpLoadBalancerFactoryConverts the passedFilterableStreamingHttpConnectionto aFilterableStreamingHttpLoadBalancedConnection.- Specified by:
toLoadBalancedConnectionin interfaceHttpLoadBalancerFactory<ResolvedAddress>- Parameters:
connection-FilterableStreamingHttpConnectionto convert- Returns:
FilterableStreamingHttpLoadBalancedConnectionfor the passedFilterableStreamingHttpConnection
-
toLoadBalancedConnection
public FilterableStreamingHttpLoadBalancedConnection toLoadBalancedConnection(FilterableStreamingHttpConnection connection, ReservableRequestConcurrencyController concurrencyController, @Nullable ContextMap context) Description copied from interface:HttpLoadBalancerFactoryConverts the passedFilterableStreamingHttpConnectionto aFilterableStreamingHttpLoadBalancedConnection.- Specified by:
toLoadBalancedConnectionin interfaceHttpLoadBalancerFactory<ResolvedAddress>- Parameters:
connection-FilterableStreamingHttpConnectionto convertconcurrencyController-ReservableRequestConcurrencyControllerto control access to the connectioncontext- Acontextof the caller (e.g. request/LB context) ornullif no context- Returns:
FilterableStreamingHttpLoadBalancedConnectionfor the passedFilterableStreamingHttpConnection.
-
requiredOffloads
Description copied from interface:ExecutionStrategyInfluencerReturn anExecutionStrategythat describes the offloads required by the influencer.- Specified by:
requiredOffloadsin interfaceExecutionStrategyInfluencer<ResolvedAddress>- Specified by:
requiredOffloadsin interfaceHttpLoadBalancerFactory<ResolvedAddress>- Specified by:
requiredOffloadsin interfaceLoadBalancerFactory<ResolvedAddress,FilterableStreamingHttpLoadBalancedConnection> - Returns:
- the
ExecutionStrategyrequired by the influencer.
-