spring-cloud-example

Learning by doing: Spring Cloud

GPL-3.0 License

Stars
14

Spring Cloud Example

  [Spring Cloud](http://spring-projects.ru/projects/spring-cloud/)  [Kotlin](https://kotlinlang.ru/)  .

:

💚 -.

Cloud-native - , .

, , , HTTP. - . . .

(c) vkhorikov /

  ,  "".           . 

_ ?_

Service Discovery

URL
discovery-server http://host:8761/eureka

Spring Cloud :

  • Spring Cloud Consul

  • Spring Cloud Zookeeper

  • Spring Cloud Netflix

      - Spring Cloud Netflix.     Netflix      .
    
      Eureka.     ,      (   Eureka).
    

, (Discovery servers) , . :

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true    

Eureka , , , . , , Discovery Server - , .

Eureka :

  • (   ).
    
  • __ Discovery .
  • , .

Eureka (aka , dashboard) . .

  http://localhost:8761

Weather Service

URL
weather-service http://host:port/weather

@EnableDiscoveryClient , WeatherServiceApplication Discovery Server Discovery Server .

Weather App

URL
weather-app http://host:port/current/weather

Datetime Service

URL
datetime-service http://host:port/datetime

@EnableDiscoveryClient , DatetimeServiceApplication Discovery Server Discovery Server .

Datetime App

URL
datetime-app http://host:port/current/datetime

Client

URL
client http://host:port

@EnableDiscoveryClient , ClientApplication Discovery Server.

   Eureka,     ,   - .      false:

eureka.client.register-with-eureka=false

 ,      ...  .

       (cascading failure) - ,        .

?

  • .
    > - . , .
  • (graceful degradation)
    > .

" " (Circuit breaker design pattern) - , . .

Hystrix

Netflix Hystrix - ...

. ?

Hystrix

URL
hystrix-dashboard http://host:port/hystrix

: Circuit Breaker: Hystrix Dashboard( .)

Turbine

Module URL
turbine http://host:3000/turbine.stream

Hystrix . , , . .

Turbine ( Spring Cloud Netflix) (streams) Hystrix , Hystrix .

:

turbine.app-config=weather-app,datetime-app
turbine.cluster-name-expression='default'

    .
  1. .

  2. .

  3. 📗 TODO

    : [Gradle](https://gradle.org/)    .
    

IntelliJ IDEA, STS / Eclipse, NetBeans .

Gradle

./gradlew :discovery-server:bootRun
./gradlew :weather-service:bootRun
./gradlew :weather-app:bootRun
./gradlew :client:bootRun
./gradlew :datetime-service:bootRun
./gradlew :datetime-app:bootRun
./gradlew :turbine:bootRun
./gradlew :hystrix-dashboard:bootRun

IntelliJ IDEA

  1. ( build.gradle) IntelliJ IDEA.
  2. Gradle (      ,       ).
    
  3.       ,     .    :
    
    1. DiscoveryServerApplication
    2. WeatherServiceApplication
    3. WeatherAppApplication
    4. ClientApplication
    5. DatetimeServiceApplication
    6. DatetimeAppApplication
    7. TurbineApplication
    8. HystrixDashboardApplication

: , , .

📗 TODO

Travis CI

 [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.ru.html).

: Google Code Archive.