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 theConnectionFactorydecorated 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 passedoriginalConnectionFactoryto add the filtering logic.static <RA,C extends ListenableAsyncCloseable>
ConnectionFactoryFilter<RA,C> identity()Returns a function that always returns its inputConnectionFactory.default ExecutionStrategyReturn anExecutionStrategythat 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 passedoriginalConnectionFactoryto add the filtering logic.- Parameters:
original-ConnectionFactoryto filter.- Returns:
- Decorated
ConnectionFactorythat 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 theConnectionFactorydecorated 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 thebeforefunction 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
beforefunction and then applies this function
-
requiredOffloads
Return anExecutionStrategythat describes the offloads required by the influencer.If the returned strategy extends
ConnectExecutionStrategythen the connection creation or accept may be offloaded.If the returned strategy extends
HttpExecutionStrategythen 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:
requiredOffloadsin interfaceExecutionStrategyInfluencer<ResolvedAddress>- Returns:
- the
ExecutionStrategyrequired 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 theConnectionFactorydecorated by this filter.- Parameters:
original- connection factory filter to be wrapped.strategy- execution strategy for the wrapped filter- Returns:
- wrapped
ConnectionFactoryFilter
-