Package io.servicetalk.client.api
Interface LimitingConnectionFactoryFilter.ConnectionLimiter<ResolvedAddress,C extends ListenableAsyncCloseable>
-
- Type Parameters:
ResolvedAddress- The type of a resolved address that can be used for connecting.C- The type of connections created by this factory.
- Enclosing class:
- LimitingConnectionFactoryFilter<ResolvedAddress,C extends ListenableAsyncCloseable>
public static interface LimitingConnectionFactoryFilter.ConnectionLimiter<ResolvedAddress,C extends ListenableAsyncCloseable>A contract to limit number of connections created byLimitingConnectionFactoryFilter.The following rules apply:
isConnectAllowed(Object)MUST be called before callingonConnectionClose(Object).onConnectionClose(Object)MAY be called at most once for each call toisConnectAllowed(Object).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanisConnectAllowed(ResolvedAddress target)Requests permission to create a single connection to the passedtarget address.default java.lang.ThrowablenewConnectionRefusedException(ResolvedAddress target)Create aThrowablerepresenting a connection attempt refused, typically as a result of returningfalsefromisConnectAllowed(Object).voidonConnectionClose(ResolvedAddress target)Callback invoked when a connection created after getting permission fromisConnectAllowed(Object)is closed.
-
-
-
Method Detail
-
isConnectAllowed
boolean isConnectAllowed(ResolvedAddress target)
Requests permission to create a single connection to the passedtarget address. If this method returnstruethenonConnectionClose(Object)will be called when the connection created by the caller is closed.A simple counting implementation will typically increment the count in this method and decrement it in
onConnectionClose(Object).- Parameters:
target-LimitingConnectionFactoryFilter.ConnectionLimiterfor which connection is requested.- Returns:
trueif connection is allowed.
-
onConnectionClose
void onConnectionClose(ResolvedAddress target)
Callback invoked when a connection created after getting permission fromisConnectAllowed(Object)is closed.- Parameters:
target-LimitingConnectionFactoryFilter.ConnectionLimiterto which connection was created.
-
newConnectionRefusedException
default java.lang.Throwable newConnectionRefusedException(ResolvedAddress target)
Create aThrowablerepresenting a connection attempt refused, typically as a result of returningfalsefromisConnectAllowed(Object).- Parameters:
target-LimitingConnectionFactoryFilter.ConnectionLimiterfor which connection was refused.- Returns:
Throwablerepresenting a connection attempt was refused.
-
-