Commit 3ef58cdc by Dave Syer

Change DiscoveryClient->EurekaClient in docs

parent 17dc4f6f
...@@ -193,17 +193,17 @@ unique. In Cloudfoundry the `spring.application.instance_id` will be ...@@ -193,17 +193,17 @@ unique. In Cloudfoundry the `spring.application.instance_id` will be
populated automatically in a Spring Boot Actuator application, so the populated automatically in a Spring Boot Actuator application, so the
random value will not be needed. random value will not be needed.
=== Using the DiscoveryClient === Using the EurekaClient
Once you have an app that is `@EnableEurekaClient` you can use it to Once you have an app that is `@EnableDiscoveryClient` (or `@EnableEurekaClient`) you can use it to
discover service instances from the <<spring-cloud-eureka-server, discover service instances from the <<spring-cloud-eureka-server,
Eureka Server>>. One way to do that is to use the native Eureka Server>>. One way to do that is to use the native
`com.netflix.discovery.DiscoveryClient` (as opposed to the Spring `com.netflix.discovery.EurekaClient` (as opposed to the Spring
Cloud `DiscoveryClient`), e.g. Cloud `DiscoveryClient`), e.g.
---- ----
@Autowired @Autowired
private DiscoveryClient discoveryClient; private EurekaClient discoveryClient;
public String serviceUrl() { public String serviceUrl() {
InstanceInfo instance = discoveryClient.getNextServerFromEureka("STORES", false); InstanceInfo instance = discoveryClient.getNextServerFromEureka("STORES", false);
...@@ -213,16 +213,16 @@ public String serviceUrl() { ...@@ -213,16 +213,16 @@ public String serviceUrl() {
[TIP] [TIP]
==== ====
Don't use the `DiscoveryClient` in `@PostConstruct` method or in a Don't use the `EurekaClient` in `@PostConstruct` method or in a
`@Scheduled` method (or anywhere where the `ApplicationContext` might `@Scheduled` method (or anywhere where the `ApplicationContext` might
not be started yet). It is initialized in a `SmartLifecycle` (with not be started yet). It is initialized in a `SmartLifecycle` (with
`phase=0`) so the earliest you can rely on it being available is in `phase=0`) so the earliest you can rely on it being available is in
another `SmartLifecycle` with higher phase. another `SmartLifecycle` with higher phase.
==== ====
=== Alternatives to the native Netflix DiscoveryClient === Alternatives to the native Netflix EurekaClient
You don't have to use the raw Netflix `DiscoveryClient` and usually it You don't have to use the raw Netflix `EurekaClient` and usually it
is more convenient to use it behind a wrapper of some sort. Spring is more convenient to use it behind a wrapper of some sort. Spring
Cloud has support for <<spring-cloud-feign, Feign>> (a REST client Cloud has support for <<spring-cloud-feign, Feign>> (a REST client
builder) and also <<spring-cloud-ribbon, Spring `RestTemplate`>> using builder) and also <<spring-cloud-ribbon, Spring `RestTemplate`>> using
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment