Skip to content

Commit

Permalink
pushing all things =)
Browse files Browse the repository at this point in the history
  • Loading branch information
chavesrodolfo committed Oct 10, 2017
1 parent c520079 commit 075e810
Show file tree
Hide file tree
Showing 38 changed files with 954 additions and 177 deletions.
9 changes: 9 additions & 0 deletions config-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM openjdk:8

VOLUME /tmp
RUN mkdir /microservice
WORKDIR /microservice
COPY ./target/config-server.jar ./config-server.jar
RUN bash -c 'touch config-server.jar'

CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "config-server.jar"]
89 changes: 89 additions & 0 deletions config-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>br.com.dodz</groupId>
<artifactId>config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>config-server</name>
<description>Spring Cloud Config Server</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Dalston.SR2</spring-cloud.version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>

<!-- Spring Cloud Stuff -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- Spring Cloud Bus -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package br.com.dodz.configserver;

import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.config.server.EnableConfigServer;

@EnableConfigServer
@SpringCloudApplication
public class ConfigServerApplication {

public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
7 changes: 7 additions & 0 deletions config-server/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
______ ______ .__ __. _______ __ _______ _______. _______ .______ ____ ____ _______ .______
/ | / __ \ | \ | | | ____|| | / _____| / || ____|| _ \ \ \ / / | ____|| _ \
| ,----'| | | | | \| | | |__ | | | | __ | (----`| |__ | |_) | \ \/ / | |__ | |_) |
| | | | | | | . ` | | __| | | | | |_ | \ \ | __| | / \ / | __| | /
| `----.| `--' | | |\ | | | | | | |__| | .----) | | |____ | |\ \----. \ / | |____ | |\ \----.
\______| \______/ |__| \__| |__| |__| \______| |_______/ |_______|| _| `._____| \__/ |_______|| _| `._____|

10 changes: 10 additions & 0 deletions config-server/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server.port: 8888

spring:
application:
name: config-server
index: ${random.int}
cloud.config:
server:
git.uri: https://github.com/chavesrodolfo/poc-microservices-config.git
bootstrap: true
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package br.com.dodz.eurekaclientone;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@FeignClient(value = "client-two")
public interface FeignClientTwo {

@RequestMapping(value = "/api/hi", method = RequestMethod.GET)
String sayHiByClientTwo();
}
package br.com.dodz.eurekaclientone;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@FeignClient(value = "eureka-client-two")
public interface FeignEurekaClientTwo {

@RequestMapping(value = "/api/hi", method = RequestMethod.GET)
String sayHiByEurekaClientTwo();
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
package br.com.dodz.eurekaclientone;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class RestService {

@Autowired
private FeignClientTwo feignClientTwo;

@RequestMapping(value = "/hi", method = RequestMethod.GET)
public ResponseEntity<String> sayHi() {
return new ResponseEntity<>("Hi From Cliente One!", HttpStatus.OK);
}

@RequestMapping(value = "/hy", method = RequestMethod.GET)
public ResponseEntity<String> sayHiUsingClientTwo() {
return new ResponseEntity<>(feignClientTwo.sayHiByClientTwo() + " using Hystrix.", HttpStatus.OK);
}

}
package br.com.dodz.eurekaclientone;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class RestService {

@Autowired
private FeignEurekaClientTwo feignEurekaClientTwo;

@RequestMapping(value = "/hi", method = RequestMethod.GET)
public ResponseEntity<String> sayHi() {
return new ResponseEntity<>("Hi From Cliente One!", HttpStatus.OK);
}

@RequestMapping(value = "/hy", method = RequestMethod.GET)
public ResponseEntity<String> sayHiUsingClientTwo() {
return new ResponseEntity<>(feignEurekaClientTwo.sayHiByEurekaClientTwo() + " using Feign.", HttpStatus.OK);
}

}
2 changes: 0 additions & 2 deletions eureka-client-one/src/main/resources/application.properties

This file was deleted.

7 changes: 7 additions & 0 deletions eureka-client-one/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.___ ___. __ ______ .______ ______ _______. _______ .______ ____ ____ __ ______ _______
| \/ | | | / || _ \ / __ \ / || ____|| _ \ \ \ / / | | / || ____|
| \ / | | | | ,----'| |_) | | | | | | (----`| |__ | |_) | \ \/ / | | | ,----'| |__
| |\/| | | | | | | / | | | | \ \ | __| | / \ / | | | | | __|
| | | | | | | `----.| |\ \----.| `--' | .----) | | |____ | |\ \----. \ / | | | `----.| |____
|__| |__| |__| \______|| _| `._____| \______/ |_______/ |_______|| _| `._____| \__/ |__| \______||_______|

12 changes: 12 additions & 0 deletions eureka-client-one/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CONFIG_SERVER_URL: http://127.0.0.1:8888

server:
port: 8081

spring:
application:
name: eureka-client-one
cloud:
config:
uri: ${CONFIG_SERVER_URL}
fail-fast: true
2 changes: 0 additions & 2 deletions eureka-client-two/src/main/resources/application.properties

This file was deleted.

7 changes: 7 additions & 0 deletions eureka-client-two/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.___ ___. __ ______ .______ ______ _______. _______ .______ ____ ____ __ ______ _______
| \/ | | | / || _ \ / __ \ / || ____|| _ \ \ \ / / | | / || ____|
| \ / | | | | ,----'| |_) | | | | | | (----`| |__ | |_) | \ \/ / | | | ,----'| |__
| |\/| | | | | | | / | | | | \ \ | __| | / \ / | | | | | __|
| | | | | | | `----.| |\ \----.| `--' | .----) | | |____ | |\ \----. \ / | | | `----.| |____
|__| |__| |__| \______|| _| `._____| \______/ |_______/ |_______|| _| `._____| \__/ |__| \______||_______|

12 changes: 12 additions & 0 deletions eureka-client-two/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CONFIG_SERVER_URL: http://127.0.0.1:8888

server:
port: 8082

spring:
application:
name: eureka-client-two
cloud:
config:
uri: ${CONFIG_SERVER_URL}
fail-fast: true
Loading

0 comments on commit 075e810

Please sign in to comment.