Commit c22f87d3 authored by Benjamin Wilms's avatar Benjamin Wilms

add examples

parent 8729e41a
......@@ -25,7 +25,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
package de.codecentric.resilience.eureka;
import com.netflix.discovery.EurekaClient;
import com.netflix.discovery.shared.Application;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@SpringBootApplication
@EnableDiscoveryClient
@EnableEurekaClient
public class EurekaClientApp {
public static void main(String[] args) {
......@@ -23,26 +23,14 @@ public class EurekaClientApp {
class ServiceInstanceRestController {
@Autowired
private DiscoveryClient discoveryClient;
private EurekaClient eurekaClient;
@RequestMapping("/services")
public List<String> serviceInstancesByApplicationName() {
return this.discoveryClient.getServices();
}
@RequestMapping("/service-details")
public EurekaResponse serviceInstancesDetails() {
EurekaResponse eurekaResponse = new EurekaResponse();
List<String> services = this.discoveryClient.getServices();
eurekaResponse.setServices(services);
services.stream().forEach(service -> {
List<ServiceInstance> serviceInstances = this.discoveryClient.getInstances(service);
eurekaResponse.getServiceInstanceList().addAll(serviceInstances);
});
@RequestMapping("/services")
public List<Application> serviceInstancesByApplicationName() {
return eurekaClient.getApplications().getRegisteredApplications();
return eurekaResponse;
}
}
}
spring.application.name=eureka-client
server.port=8099
\ No newline at end of file
server.port=8099
security.basic.enabled=false
management.security.enabled=false
\ No newline at end of file
......@@ -30,6 +30,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -4,4 +4,7 @@ eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
logging.level.com.netflix.eureka=OFF
logging.level.com.netflix.discovery=OFF
\ No newline at end of file
logging.level.com.netflix.discovery=OFF
security.basic.enabled=false
management.security.enabled=false
\ No newline at end of file
......@@ -3,4 +3,9 @@ server:
spring:
application:
name: greeting-app
security:
basic:
enabled: false
management:
security:
enabled: false
......@@ -2,4 +2,10 @@ server:
port: 8010
spring:
application:
name: greeting-app
\ No newline at end of file
name: greeting-app
security:
basic:
enabled: false
management:
security:
enabled: false
......@@ -3,4 +3,10 @@ say-hello:
eureka:
enabled: false
listOfServers: localhost:8010,localhost:9092,localhost:9999
ServerListRefreshInterval: 15000
\ No newline at end of file
ServerListRefreshInterval: 15000
security:
basic:
enabled: false
management:
security:
enabled: false
\ No newline at end of file
......@@ -34,6 +34,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......
......@@ -34,6 +34,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......
spring:
application:
name: greeting-client
\ No newline at end of file
name: greeting-client
security:
basic:
enabled: false
management:
security:
enabled: false
\ No newline at end of file
......@@ -41,6 +41,10 @@
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
......
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