Package org.kiwiproject.registry.client
Class MultiRegistryClient
- java.lang.Object
-
- org.kiwiproject.registry.client.MultiRegistryClient
-
- All Implemented Interfaces:
RegistryClient
public class MultiRegistryClient extends Object implements RegistryClient
ARegistryClientthat finds services in more than one registry.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.kiwiproject.registry.client.RegistryClient
RegistryClient.InstanceQuery
-
-
Constructor Summary
Constructors Constructor Description MultiRegistryClient(List<RegistryClient> registryClients)Construct a new instance with the specfiedRegistryClients to use when performing service lookups.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ServiceInstance>findAllServiceInstancesBy(RegistryClient.InstanceQuery query)Attempts to find all service instances from the givenRegistryClient.InstanceQuery.Optional<ServiceInstance>findServiceInstanceBy(String serviceName, String instanceId)Attempts to find a service instance with the given service name and the given instance id.static MultiRegistryClientof(RegistryClient... registryClients)Factory method to create a new instance from the givenRegistryClients.List<ServiceInstance>retrieveAllRegisteredInstances()Retrieves all registered service instances from the registry.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.kiwiproject.registry.client.RegistryClient
findAllServiceInstancesBy, findServiceInstanceBy, findServiceInstanceBy
-
-
-
-
Constructor Detail
-
MultiRegistryClient
public MultiRegistryClient(List<RegistryClient> registryClients)
Construct a new instance with the specfiedRegistryClients to use when performing service lookups. The order in the provided list is the order in which the service lookups will occur.- Parameters:
registryClients- a list ofRegistryClientinstances to use; must have at least one RegistryClient
-
-
Method Detail
-
of
public static MultiRegistryClient of(RegistryClient... registryClients)
Factory method to create a new instance from the givenRegistryClients.- Parameters:
registryClients- theRegistryClientinstances to use; must have at least one RegistryClient- Returns:
- a new MultiRegistryClient instance
-
findServiceInstanceBy
public Optional<ServiceInstance> findServiceInstanceBy(String serviceName, String instanceId)
Attempts to find a service instance with the given service name and the given instance id.Returns the first
ServiceInstanceit finds, checking eachRegistryClientin order.- Specified by:
findServiceInstanceByin interfaceRegistryClient- Parameters:
serviceName- The name of the service that is being requestedinstanceId- The id of the instance that is wanted- Returns:
- an
Optionalcontaining the found service orOptional.empty()
-
findAllServiceInstancesBy
public List<ServiceInstance> findAllServiceInstancesBy(RegistryClient.InstanceQuery query)
Attempts to find all service instances from the givenRegistryClient.InstanceQuery.Returns all services that match the query from all
RegistryClients that return any results, checking eachRegistryClientin order.- Specified by:
findAllServiceInstancesByin interfaceRegistryClient- Parameters:
query- aRegistryClient.InstanceQuerycontaining the search parameters to find the instance- Returns:
- a
Listcontaining the found services
-
retrieveAllRegisteredInstances
public List<ServiceInstance> retrieveAllRegisteredInstances()
Retrieves all registered service instances from the registry.Returns all registered services from all
RegistryClients that return any results, checking eachRegistryClientin order.- Specified by:
retrieveAllRegisteredInstancesin interfaceRegistryClient- Returns:
- a
Listcontaining all registered service instances
-
-