-
Notifications
You must be signed in to change notification settings - Fork 31
io microsphere spring cloud client discovery UnionDiscoveryClient
Type: Class | Module: microsphere-spring-cloud-commons | Package: io.microsphere.spring.cloud.client.discovery | Since: 1.0.0
The DiscoveryClient implementation for a union of the given DiscoveryClient
public final class UnionDiscoveryClient implements DiscoveryClient, ApplicationContextAware, SmartInitializingSingleton, DisposableBeanAuthor: Mercy
-
Introduced in:
1.0.0 -
Current Project Version:
0.2.5-SNAPSHOT
This component is tested and compatible with the following Java versions:
| Java Version | Status |
|---|---|
| Java 17 | ✅ Compatible |
| Java 21 | ✅ Compatible |
| Java 25 | ✅ Compatible |
UnionDiscoveryClient unionClient = applicationContext.getBean(UnionDiscoveryClient.class);
List<DiscoveryClient> clients = unionClient.getDiscoveryClients();
clients.forEach(c -> System.out.println(c.description()));Add the following dependency to your pom.xml:
<dependency>
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-spring-cloud-commons</artifactId>
<version>${microsphere-spring-cloud.version}</version>
</dependency>Tip: Use the BOM (
microsphere-spring-cloud-dependencies) for consistent version management. See the Getting Started guide.
import io.microsphere.spring.cloud.client.discovery.UnionDiscoveryClient;| Method | Description |
|---|---|
description |
{@inheritDoc} |
getInstances |
{@inheritDoc} |
getServices |
{@inheritDoc} |
getDiscoveryClients |
Returns the sorted list of underlying DiscoveryClient DiscoveryClients, excluding |
getOrder |
{@inheritDoc} |
afterSingletonsInstantiated |
{@inheritDoc} |
destroy |
{@inheritDoc} |
setApplicationContext |
{@inheritDoc} |
public List<ServiceInstance> getInstances(String serviceId){@inheritDoc}
Aggregates service instances from all underlying DiscoveryClient DiscoveryClients.
public List<String> getServices(){@inheritDoc}
Returns a deduplicated union of service names from all underlying DiscoveryClient DiscoveryClients.
public List<DiscoveryClient> getDiscoveryClients()Returns the sorted list of underlying DiscoveryClient DiscoveryClients, excluding
CompositeDiscoveryClient and this instance itself. The list is lazily initialized
from the ApplicationContext on first access and cached for subsequent calls.
Example Usage:
`UnionDiscoveryClient unionClient = applicationContext.getBean(UnionDiscoveryClient.class); List clients = unionClient.getDiscoveryClients(); clients.forEach(c -> System.out.println(c.description())); `
public void afterSingletonsInstantiated(){@inheritDoc}
Eagerly initializes the list of DiscoveryClient DiscoveryClients after all singletons are instantiated.
public void destroy(){@inheritDoc}
Clears the cached list of DiscoveryClient DiscoveryClients on bean destruction.
public void setApplicationContext(ApplicationContext applicationContext){@inheritDoc}
Stores the ApplicationContext used to look up DiscoveryClient beans.
CompositeDiscoveryClient
This documentation was auto-generated from the source code of microsphere-spring-cloud.
spring-cloud-commons
- AbstractServiceRegistrationEndpoint
- CommonsPropertyConstants
- ConditionalOnAutoServiceRegistrationEnabled
- ConditionalOnFeaturesEnabled
- ConditionalOnLoadBalancerEnabled
- ConditionalOnMultipleRegistrationEnabled
- ConditionalOnUtilEnabled
- DefaultRegistration
- DiscoveryClientAutoConfiguration
- DiscoveryClientConstants
- DiscoveryUtils
- EventPublishingRegistrationAspect
- FaultTolerancePropertyConstants
- InMemoryServiceRegistry
- InstanceConstants
- LoadBalancerUtils
- MultipleAutoServiceRegistration
- MultipleRegistration
- MultipleServiceRegistry
- ReactiveDiscoveryClientAdapter
- ReactiveDiscoveryClientAutoConfiguration
- RegistrationCustomizer
- RegistrationDeregisteredEvent
- RegistrationEvent
- RegistrationMetaData
- RegistrationPreDeregisteredEvent
- RegistrationPreRegisteredEvent
- RegistrationRegisteredEvent
- ServiceDeregistrationEndpoint
- ServiceInstanceUtils
- ServiceInstancesChangedEvent
- ServiceRegistrationEndpoint
- ServiceRegistrationEndpointAutoConfiguration
- ServiceRegistryAutoConfiguration
- SimpleAutoServiceRegistration
- SimpleAutoServiceRegistrationAutoConfiguration
- SimpleServiceRegistry
- SpecificationAutoConfiguration
- SpecificationBeanPostProcessor
- SpecificationCustomizer
- SpringCloudPropertyConstants
- TomcatDynamicConfigurationListener
- TomcatFaultToleranceAutoConfiguration
- UnionDiscoveryClient
- WebFluxServiceRegistryAutoConfiguration
- WebMvcServiceRegistryAutoConfiguration
- WebServiceRegistryAutoConfiguration
- WeightedRoundRobin
spring-cloud-openfeign
- AutoRefreshCapability
- AutoRefreshCapabilityCustomizer
- CompositedRequestInterceptor
- DecoratedContract
- DecoratedDecoder
- DecoratedEncoder
- DecoratedErrorDecoder
- DecoratedFeignComponent
- DecoratedQueryMapEncoder
- DecoratedRetryer
- EnableFeignAutoRefresh
- FeignAutoConfiguration
- FeignClientAutoRefreshAutoConfiguration
- FeignClientConfigurationChangedListener
- FeignComponentRegistry
- NoOpRequestInterceptor
- Refreshable