diff --git a/docs/src/main/asciidoc/spring-cloud-netflix.adoc b/docs/src/main/asciidoc/spring-cloud-netflix.adoc index 74f96ab9..45bb61c6 100644 --- a/docs/src/main/asciidoc/spring-cloud-netflix.adoc +++ b/docs/src/main/asciidoc/spring-cloud-netflix.adoc @@ -160,7 +160,7 @@ not be started yet). It is initialized in a `SmartLifecycle` (with another `SmartLifecycle` with higher phase. ==== -=== Alternatives to the DiscoveryClient +=== Alternatives to the native Netflix DiscoveryClient You don't have to use the raw Netflix `DiscoveryClient` and usually it is more convenient to use it behind a wrapper of some sort. Spring @@ -172,6 +172,23 @@ can simply set `.ribbon.listOfServers` to a comma-separated list of physical addresses (or hostnames), where `` is the ID of the client. +You can also use the `org.springframework.cloud.client.discovery.DiscoveryClient` +which provides a simple API for discovery clients that is not specific +to Netflix, e.g. + +---- +@Autowired +private DiscoveryClient discoveryClient; + +public String serviceUrl() { + List list = client.getInstances("STORES"); + if (list != null && list.size() > 0 ) { + return list.get(0).getUri(); + } + return null; +} +---- + === Why is it so Slow to Register a Service? Being an instance also involves a periodic heartbeat to the registry