Package io.servicetalk.client.api
Interface ClientGroup<Key,Client extends ListenableAsyncCloseable>
-
- Type Parameters:
Key
- the type of key used for client lookupClient
- the type of client stored in the group
- All Superinterfaces:
AsyncCloseable
,ListenableAsyncCloseable
- All Known Implementing Classes:
DefaultPartitionedClientGroup
public interface ClientGroup<Key,Client extends ListenableAsyncCloseable> extends ListenableAsyncCloseable
A data-structure capable of holding arbitrary number of clients and bridging lifecycle events across all clients managed by the group.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <Key,Client extends ListenableAsyncCloseable>
ClientGroup<Key,Client>from(java.util.function.Function<Key,Client> factory)
Client
get(Key key)
Return theClientGroup
identified by the providedkey
or create a new one when none exists.-
Methods inherited from interface io.servicetalk.concurrent.api.AsyncCloseable
closeAsync, closeAsyncGracefully
-
Methods inherited from interface io.servicetalk.concurrent.api.ListenableAsyncCloseable
onClose
-
-
-
-
Method Detail
-
get
Client get(Key key)
Return theClientGroup
identified by the providedkey
or create a new one when none exists.- Parameters:
key
- the key identifying the client to return or create, this key may contain attributes about the requested client in order to create new instances- Returns:
- a client assigned to the provided
key
, either by looking up an existing or creating a new instance if non-existent
-
from
static <Key,Client extends ListenableAsyncCloseable> ClientGroup<Key,Client> from(java.util.function.Function<Key,Client> factory)
- Type Parameters:
Key
- the type of key used for client lookup and creationClient
- the type of client stored in the group- Parameters:
factory
-Function
will be called every timeget(Object)
is called with a non-existentClientGroup
.- Returns:
- a
ClientGroup
based on a @{code factory} of clients of typeClientGroup
.
-
-