ResolvedAddress
- The type of a resolved address that can be used for connecting.C
- The type of connections created by this factory.public static interface LimitingConnectionFactoryFilter.ConnectionLimiter<ResolvedAddress,C extends ListenableAsyncCloseable>
LimitingConnectionFactoryFilter
.
The following rules apply:
isConnectAllowed(Object)
MUST be called before calling
onConnectionClose(Object)
.onConnectionClose(Object)
MAY be called at most once for each call to
isConnectAllowed(Object)
.Modifier and Type | Method and Description |
---|---|
boolean |
isConnectAllowed(ResolvedAddress target)
Requests permission to create a single connection to the passed
target address . |
default java.lang.Throwable |
newConnectionRefusedException(ResolvedAddress target)
Create a
Throwable representing a connection attempt refused, typically as a result of returning
false from isConnectAllowed(Object) . |
void |
onConnectionClose(ResolvedAddress target)
Callback invoked when a connection created after getting permission from
isConnectAllowed(Object) is closed. |
boolean isConnectAllowed(ResolvedAddress target)
target address
.
If this method returns true
then onConnectionClose(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)
.
target
- ResolvedAddress
for which connection is requested.true
if connection is allowed.void onConnectionClose(ResolvedAddress target)
isConnectAllowed(Object)
is closed.target
- ResolvedAddress
to which connection was created.default java.lang.Throwable newConnectionRefusedException(ResolvedAddress target)
Throwable
representing a connection attempt refused, typically as a result of returning
false
from isConnectAllowed(Object)
.target
- ResolvedAddress
for which connection was refused.Throwable
representing a connection attempt was refused.