Skip to content

Commit eb08c8c

Browse files
author
OlgaMaciaszek
committed
Add documentation for the new functionality.
1 parent 3534e16 commit eb08c8c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/src/main/asciidoc/spring-cloud-commons.adoc

+24
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,30 @@ To disable it, set `spring.cloud.discovery.client.health-indicator.enabled=false
235235
To disable the description field of the `DiscoveryClientHealthIndicator`, set `spring.cloud.discovery.client.health-indicator.include-description=false`.
236236
Otherwise, it can bubble up as the `description` of the rolled up `HealthIndicator`.
237237

238+
==== Ordering `DiscoveryClient` instances
239+
`DiscoveryClient` interface extends `Ordered` to let you define the order of the returned discovery clients, similar to
240+
how you can order the beans loaded by a Spring application. By default, the order of any `DiscoveryClient` is set to
241+
`Ordered.LOWEST_PRECEDENCE`, which equals `Integer.MAX_VALUE`. If you want to set a different order for your custom
242+
`DiscoveryClient` implementations, you just need to override the `getOrder()` method so that it returns the value that
243+
is suitable for your setup. Apart from this, you can use properties to set the order of the `DiscoveryClient`
244+
implementations provided by Spring Cloud, among others `ConsulDiscoveryClient`, `EurekaDiscoveryClient` and
245+
`ZookeeperDiscoveryClient`. In order to do it, you just need to set the
246+
`spring.cloud.discovery.client.{clientIdentifier}.order` property to the desired value.
247+
248+
The following example shows how to set order value for Spring Cloud `DiscoveryClient` implementations:
249+
250+
[source,yaml,indent=0]
251+
----
252+
spring:
253+
cloud:
254+
discovery:
255+
client:
256+
eureka: 1
257+
----
258+
259+
The following client identifiers are currently supported with this syntax: `eureka`, `consul`, `zookeeper`,
260+
`cloudfoundry`, `simple`.
261+
238262
=== ServiceRegistry
239263

240264
Commons now provides a `ServiceRegistry` interface that provides methods such as `register(Registration)` and `deregister(Registration)`, which let you provide custom registered services.

0 commit comments

Comments
 (0)