Interface ClientGroup<Key,Client extends ListenableAsyncCloseable>

Type Parameters:
Key - the type of key used for client lookup
Client - 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 Details

    • get

      Client get(Key key)
      Return the ClientGroup identified by the provided key 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(Function<Key,Client> factory)
      Creates a ClientGroup based on a factory of clients of type Client.
      Type Parameters:
      Key - the type of key used for client lookup and creation
      Client - the type of client stored in the group
      Parameters:
      factory - Function will be called every time get(Object) is called with a non-existent ClientGroup.
      Returns:
      a ClientGroup based on a @{code factory} of clients of type ClientGroup.