Package io.servicetalk.client.api
Interface ConnectionFactoryFilter<ResolvedAddress,C extends ListenableAsyncCloseable>
- Type Parameters:
ResolvedAddress
- The type of resolved addresses that can be used for connecting.C
- The type of connections created by theConnectionFactory
decorated by this filter.
- All Superinterfaces:
ExecutionStrategyInfluencer<ExecutionStrategy>
- All Known Implementing Classes:
DelegatingConnectionFactoryFilter
,LimitingConnectionFactoryFilter
,TransportObserverConnectionFactoryFilter
- 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 ConnectionFactoryFilter<ResolvedAddress,C extends ListenableAsyncCloseable>
extends ExecutionStrategyInfluencer<ExecutionStrategy>
A contract to decorate
ConnectionFactory
instances for the purpose of filtering.-
Method Summary
Modifier and TypeMethodDescriptiondefault ConnectionFactoryFilter<ResolvedAddress,
C> append
(ConnectionFactoryFilter<ResolvedAddress, C> before) Deprecated.consider using higher level client builders to append filters.create
(ConnectionFactory<ResolvedAddress, C> original) Decorates the passedoriginal
ConnectionFactory
to add the filtering logic.static <RA,
C extends ListenableAsyncCloseable>
ConnectionFactoryFilter<RA,C> identity()
Returns a function that always returns its inputConnectionFactory
.default ExecutionStrategy
Return anExecutionStrategy
that describes the offloads required by the influencer.static <RA,
C extends ListenableAsyncCloseable>
ConnectionFactoryFilter<RA,C> withStrategy
(ConnectionFactoryFilter<RA, C> original, ExecutionStrategy strategy) Wraps a connection factory filter to return a specific execution strategy.
-
Method Details
-
create
Decorates the passedoriginal
ConnectionFactory
to add the filtering logic.- Parameters:
original
-ConnectionFactory
to filter.- Returns:
- Decorated
ConnectionFactory
that contains the filtering logic.
-
identity
Returns a function that always returns its inputConnectionFactory
.- Type Parameters:
RA
- The type of resolved address that can be used for connecting.C
- The type of connections created by theConnectionFactory
decorated by this filter.- Returns:
- a function that always returns its input
ConnectionFactory
.
-
append
@Deprecated default ConnectionFactoryFilter<ResolvedAddress,C> append(ConnectionFactoryFilter<ResolvedAddress, C> before) Deprecated.consider using higher level client builders to append filters.Returns a composed function that first applies thebefore
function to its input, and then applies this function to the result.The order of execution of these filters are in order of append. If 3 filters are added as follows:
factory.append(filter1).append(filter2).append(filter3)
accepting a connection by a filter wrapped by this filter chain, the order of invocation of these filters will be:filter1 ⇒ filter2 ⇒ filter3
- Parameters:
before
- the function to apply before this function is applied- Returns:
- a composed function that first applies the
before
function and then applies this function
-
requiredOffloads
Return anExecutionStrategy
that describes the offloads required by the influencer.If 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
.- Specified by:
requiredOffloads
in interfaceExecutionStrategyInfluencer<ResolvedAddress>
- Returns:
- the
ExecutionStrategy
required by the influencer.
-
withStrategy
static <RA,C extends ListenableAsyncCloseable> ConnectionFactoryFilter<RA,C> withStrategy(ConnectionFactoryFilter<RA, C> original, ExecutionStrategy strategy) Wraps a connection factory filter to return a specific execution strategy.- Type Parameters:
RA
- The type of resolved addresses that can be used for connecting.C
- The type of connections created by theConnectionFactory
decorated by this filter.- Parameters:
original
- connection factory filter to be wrapped.strategy
- execution strategy for the wrapped filter- Returns:
- wrapped
ConnectionFactoryFilter
-