ResolvedAddress - The type of a resolved address that can be used for connecting.C - The type of connections created by this factory.public final class LimitingConnectionFactoryFilter<ResolvedAddress,C extends ListenableAsyncCloseable> extends Object implements ConnectionFactoryFilter<ResolvedAddress,C>
ConnectionFactory that limits the total number of active connections created using this
ConnectionFactory. A connection is considered active if ListenableAsyncCloseable.onClose() has
not yet terminated.| Modifier and Type | Class and Description |
|---|---|
static interface |
LimitingConnectionFactoryFilter.ConnectionLimiter<ResolvedAddress,C extends ListenableAsyncCloseable>
A contract to limit number of connections created by
LimitingConnectionFactoryFilter. |
| Modifier and Type | Method and Description |
|---|---|
ConnectionFactory<ResolvedAddress,C> |
create(ConnectionFactory<ResolvedAddress,C> original)
Decorates the passed
original ConnectionFactory to add the filtering logic. |
ExecutionStrategy |
requiredOffloads() |
static <A,C extends ListenableAsyncCloseable> |
with(LimitingConnectionFactoryFilter.ConnectionLimiter<A,C> limiter)
Create a new
ConnectionFactory that limits the created connections using the passed
LimitingConnectionFactoryFilter.ConnectionLimiter. |
static <A,C extends ListenableAsyncCloseable> |
withMax(int maxConnections)
Create a new
ConnectionFactory that only creates a maximum of maxConnections active connections. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitappend, identity, withStrategypublic ExecutionStrategy requiredOffloads()
ConnectionFactoryFilterIf the returned strategy extends ConnectExecutionStrategy then the connection creation or accept may
be offloaded.
If the returned strategy extends HttpExecutionStrategy then the HTTP execution strategy will be
applied to the connections created.
A utility class provides the ability to combine connect and HTTP execution strategies,
io.servicetalk.http.api.ConnectAndHttpExecutionStrategy.
requiredOffloads in interface ConnectionFactoryFilter<ResolvedAddress,C extends ListenableAsyncCloseable>requiredOffloads in interface ExecutionStrategyInfluencer<ExecutionStrategy>public static <A,C extends ListenableAsyncCloseable> ConnectionFactoryFilter<A,C> withMax(int maxConnections)
ConnectionFactory that only creates a maximum of maxConnections active connections.
When the limit is reached, ConnectionLimitReachedException will be thrown.
A - The type of a resolved address that can be used for connecting.C - The type of connections created by the returned factory.maxConnections - Maximum number of active connections to create.ConnectionFactory that limits the number of active connections.public static <A,C extends ListenableAsyncCloseable> ConnectionFactoryFilter<A,C> with(LimitingConnectionFactoryFilter.ConnectionLimiter<A,C> limiter)
ConnectionFactory that limits the created connections using the passed
LimitingConnectionFactoryFilter.ConnectionLimiter.A - The type of a resolved address that can be used for connecting.C - The type of connections created by the returned factory.limiter - LimitingConnectionFactoryFilter.ConnectionLimiter to use.ConnectionFactory that limits the number of active connections.public ConnectionFactory<ResolvedAddress,C> create(ConnectionFactory<ResolvedAddress,C> original)
ConnectionFactoryFilteroriginal ConnectionFactory to add the filtering logic.create in interface ConnectionFactoryFilter<ResolvedAddress,C extends ListenableAsyncCloseable>original - ConnectionFactory to filter.ConnectionFactory that contains the filtering logic.