Package org.kiwiproject.registry.client
Class MultiRegistryClient
java.lang.Object
org.kiwiproject.registry.client.MultiRegistryClient
- All Implemented Interfaces:
RegistryClient
A
RegistryClient
that 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
ConstructorDescriptionMultiRegistryClient
(List<RegistryClient> registryClients) Construct a new instance with the specfiedRegistryClient
s to use when performing service lookups. -
Method Summary
Modifier and TypeMethodDescriptionAttempts to find all service instances from the givenRegistryClient.InstanceQuery
.findServiceInstanceBy
(String serviceName, String instanceId) Attempts to find a service instance with the given service name and the given instance id.static MultiRegistryClient
of
(RegistryClient... registryClients) Factory method to create a new instance from the givenRegistryClient
s.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 Details
-
MultiRegistryClient
Construct a new instance with the specfiedRegistryClient
s 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 ofRegistryClient
instances to use; must have at least one RegistryClient
-
-
Method Details
-
of
Factory method to create a new instance from the givenRegistryClient
s.- Parameters:
registryClients
- theRegistryClient
instances to use; must have at least one RegistryClient- Returns:
- a new MultiRegistryClient instance
-
findServiceInstanceBy
Attempts to find a service instance with the given service name and the given instance id.Returns the first
ServiceInstance
it finds, checking eachRegistryClient
in order.- Specified by:
findServiceInstanceBy
in interfaceRegistryClient
- Parameters:
serviceName
- The name of the service that is being requestedinstanceId
- The id of the instance that is wanted- Returns:
- an
Optional
containing the found service orOptional.empty()
-
findAllServiceInstancesBy
Attempts to find all service instances from the givenRegistryClient.InstanceQuery
.Returns all services that match the query from all
RegistryClient
s that return any results, checking eachRegistryClient
in order.- Specified by:
findAllServiceInstancesBy
in interfaceRegistryClient
- Parameters:
query
- aRegistryClient.InstanceQuery
containing the search parameters to find the instance- Returns:
- a
List
containing the found services
-
retrieveAllRegisteredInstances
Retrieves all registered service instances from the registry.Returns all registered services from all
RegistryClient
s that return any results, checking eachRegistryClient
in order.- Specified by:
retrieveAllRegisteredInstances
in interfaceRegistryClient
- Returns:
- a
List
containing all registered service instances
-