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
Modifier and TypeMethodDescriptionstatic <Key,Client extends ListenableAsyncCloseable>
ClientGroup<Key,Client> Return theClientGroupidentified by the providedkeyor create a new one when none exists.Methods inherited from interface io.servicetalk.concurrent.api.AsyncCloseable
closeAsync, closeAsyncGracefullyMethods inherited from interface io.servicetalk.concurrent.api.ListenableAsyncCloseable
onClose, onClosing
-
Method Details
-
get
Return theClientGroupidentified by the providedkeyor 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(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-Functionwill be called every timeget(Object)is called with a non-existentClientGroup.- Returns:
- a
ClientGroupbased on a @{code factory} of clients of typeClientGroup.
-