I analysed this repository according to the clean code standards on Better Code Hub just to get an independent opinion of how bad the code is. Surprisingly, the compliance score is high!
Let's explain first the system structure to understand its components:
Springy Store μService --> Parent folder.
|- config --> All system configuration files
|- docs --> All docs and diagrams.
|- store-base
|- store-build-chassis --> Super Parent POM, contains all build information
|- store-cloud-chassis --> Cloud services Parent POM, inherit from build contains all cloud libraries
|- store-service-chassis --> Parent POM, inherits from cloud contains all microservices common libraries
|-store-cloud-infra
|- authorization-server --> Authorization server
|- edge-server --> API Gateway server
|- eureka-server --> Service discovery server
|- config-server --> Centralized Configuration server
|-store-common
|- store-api --> API Endpoint and services definitions for all microservices
|- store-utils --> Common utilities shared between all components
|-store-services
|- product-service --> Product Microservice
|- recommendation-service --> Recommendation Microservice
|- review-service --> Review Microservice
|- store-service --> Store Microservice
|- docker-compose.yml --> contains all services landscape with RabbitMQ
|- docker-compose-kafka.yml --> contains all services landscape with more instances working with Kafka with partitions
|- docker-compose-partitions.yml --> contains all services landscape with more instances working with RabbitMQ with partitions
|- run-em-all.sh --> Run all microservices in separate mode.
|- setup.sh --> Install all shared POMs and shared libraries.
|- stop-em-all.sh --> Stop all services runs in standalone mode.
|- test-em-all.sh --> This will start all docker compose landscape and test them, then shutdown docker compose containers with test finishes (use switch start stop)
Now, as we have learned about different system components, then let's start.
The following are the initially required software pieces:
Maven: Apache Maven is a software project management and comprehension tool, it can be downloaded from here https://maven.apache.org/download.cgi
Git: it can be downloaded and installed from https://git-scm.com/downloads
Java 15 EA: it can be downloaded and installed from https://jdk.java.net/15/
curl: this command-line tool for testing HTTP-based APIs can be downloaded and installed from https://curl.haxx.se/download.html
jq: This command-line JSON processor can be downloaded and installed from https://stedolan.github.io/jq/download/
Spring Boot Initializer: This Initializer generates spring boot project with just what you need to start quickly! Start from here https://start.spring.io/
Docker Desktop: The fastest way to containerize applications on your desktop, and you can download it from here https://www.docker.com/products/docker-desktop
For each future stage, I will list the newly required software.
Follow the installation guide for each software website link and check your software versions from the command line to verify that they are all installed correctly.
I recommend that you work with your Java code using an IDE that supports the development of Spring Boot applications such as Spring Tool Suite or IntelliJ IDEA Ultimate Edition. So you can use the Spring Boot Dashboard to run the services, run each microservice test case, and many more.
All that you want to do is just fire up your IDE -> open or import the parent folder springy-store-microservices,
and everything will be ready for you.
The first thing to do is to open git bash command line, and then simply you can clone the project under any of your favorite places as the following:
> git clone https://github.com/mohamed-taman/Springy-Store-Microservices.git
To build and run the test cases for each service & shared modules in the project, we need to do the following:
This done only for the first time or any new changes or versions of shared modules and POMs.
To build and install store-build-chassis
, store-utils
, store-api
, store-services-chassis
, and store-cloud-chassis
libraries, from the root folder springy-store-microservices
run thefollowing commands:
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ ./setup.sh
Now you should expect output like this:
Installing all Springy store core shared modules & Parent POMs
...............................................................
1- Installing [Parent Build Chassis] module...
Done successfully.
2- Installing [Parent Cloud Chassis] module...
Done successfully.
3- Installing shared [Services Utilities] module...
Done successfully.
4- Installing shared [Services APIs] module...
Done successfully.
5- Installing [Services Parent Chassis] module...
Done successfully.
Woohoo, building & installing all project modules are finished successfully.
The project is ready for the next step. :)
Now it is the time to build our 4 microservices and run each service integration test inisolation by running the following commands:
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ ./mvnw clean verify -Ddockerfile.skip
All build commands and test suite for each microservice should run successfully, and the final output should be like this:
---------------< com.siriusxi.ms.store:store-aggregator >---------------
[INFO] Building Springy Store Aggregator 1.0-SNAPSHOT [13/13]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ store-aggregator ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Springy Store Aggregator 1.0-SNAPSHOT:
[INFO]
[INFO] Springy Store Build Chassis ........................ SUCCESS [ 0.228 s]
[INFO] Springy Store Cloud Chassis ........................ SUCCESS [ 1.257 s]
[INFO] Store APIs ......................................... SUCCESS [ 4.279 s]
[INFO] Store Utils ........................................ SUCCESS [ 1.809 s]
[INFO] Springy Store Chassis .............................. SUCCESS [ 0.857 s]
[INFO] Product Service .................................... SUCCESS [ 13.079 s]
[INFO] Review Service ..................................... SUCCESS [ 9.332 s]
[INFO] Recommendation Service ............................. SUCCESS [ 8.463 s]
[INFO] Store Service ...................................... SUCCESS [ 8.927 s]
[INFO] Eureka Discovery Server ............................ SUCCESS [ 6.536 s]
[INFO] Edge Server ........................................ SUCCESS [ 32.108 s]
[INFO] Authorization Server ............................... SUCCESS [ 1.616 s]
[INFO] Configuration Server ............................... SUCCESS [ 1.216 s]
[INFO] Springy Store Aggregator ........................... SUCCESS [ 0.100 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 57.663 s
[INFO] Finished at: 2020-05-08T03:38:34+02:00
[INFO] ------------------------------------------------------------------------
Now it's the time to run all of our reactive Microservices, and it's straightforward just run the following docker-compose
commands:
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ docker-compose -p ssm up -d
All the services, databases, and messaging service will run in parallel in detach mode (option -d
), and command output will print to the console the following:
Creating network "ssm_default" with the default driver
Creating ssm_eureka_1 ... done
Creating ssm_config-server_1 ... done
Creating ssm_gateway_1 ... done
Creating ssm_auth-server_1 ... done
Creating ssm_mysql_1 ... done
Creating ssm_mongodb_1 ... done
Creating ssm_rabbitmq_1 ... done
Creating ssm_zipkin_1 ... done
Creating ssm_store_1 ... done
Creating ssm_review_1 ... done
Creating ssm_product_1 ... done
Creating ssm_recommendation_1 ... done
You can manually test Store Service
APIs throughout its Swagger interface at the followingURL https://localhost:8443/swagger-ui.html.
If you would like to access the Eureka service discovery point to this URL http://localhosts:8443/eureka/web to see all the services registered inside it.
Note that it is accessed through API Gateway and is secured. Therefore the browser will ask you for username:mt
and password:p,
write them to the dialog, and you will access it. This type of security is a basic form security.
The API Gateway and Store Service both act as a resource server. To know more about calling Store API in a secure way you can check the test-em-all.sh
script on how I have changed the calling of the services using OAuth2 security.
In browser point to this URL http://localhost:5672/ username: guest
and password: guest
, and you can see all topics, DLQs, partitions, and payload.
docker-compose
command:
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ docker-compose -p ssm -f docker-compose-partitions.yml up -d
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ docker-compose -p ssm -f docker-compose-kafka.yml up -d
From Store front Service we can check all the core services health when you have all themicroservices up and running using Docker Compose,
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ curl -k https://localhost:8443/actuator/health -s | jq .components."\"Core Microservices\""
This will result in the following response:
{
"status": "UP",
"components": {
"Authorization Server": {
"status": "UP"
},
"Product Service": {
"status": "UP"
},
"Recommendation Service": {
"status": "UP"
},
"Review Service": {
"status": "UP"
},
"Store Service": {
"status": "UP"
}
}
}
Now it's time to test all the application functionality as one part. To do so just runthe following automation test script:
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ ./test-em-all.sh start
You can use
stop
switch withstart
, that will
- start docker,
- run the tests,
- stop the docker instances.
The result will look like this:
Starting 'Springy Store μServices' for [Blackbox] testing...
Start Tests: Tue, May 31, 2020 2:09:36 AM
HOST=localhost
PORT=8443
Restarting the test environment...
$ docker-compose -p ssm down --remove-orphans
$ docker-compose -p ssm up -d
Wait for: curl -k https://localhost:8443/actuator/health... , retry #1 , retry #2, {"status":"UP"} DONE, continues...
Test OK (HTTP Code: 200)
...
Test OK (actual value: 1)
Test OK (actual value: 3)
Test OK (actual value: 3)
Test OK (HTTP Code: 404, {"httpStatus":"NOT_FOUND","message":"No product found for productId: 13","path":"/store/api/v1/products/13","time":"2020-04-12@12:34:25.144+0000"})
...
Test OK (actual value: 3)
Test OK (actual value: 0)
Test OK (HTTP Code: 422, {"httpStatus":"UNPROCESSABLE_ENTITY","message":"Invalid productId: -1","path":"/store/api/v1/products/-1","time":"2020-04-12@12:34:26.243+0000"})
Test OK (actual value: "Invalid productId: -1")
Test OK (HTTP Code: 400, {"timestamp":"2020-04-12T12:34:26.471+00:00","path":"/store/api/v1/products/invalidProductId","status":400,"error":"Bad Request","message":"Type mismatch.","requestId":"044dcdf2-13"})
Test OK (actual value: "Type mismatch.")
Test OK (HTTP Code: 401, )
Test OK (HTTP Code: 200)
Test OK (HTTP Code: 403, )
Start Circuit Breaker tests!
Test OK (actual value: CLOSED)
Test OK (HTTP Code: 500, {"timestamp":"2020-05-26T00:09:48.784+00:00","path":"/store/api/v1/products/2","status":500,"error":"Internal Server Error","message":"Did not observe any item or terminal signal within 2000ms in 'onErrorResume' (and no fallback has been configured)","requestId":"4aa9f5e8-119"})
...
Test OK (actual value: Did not observe any item or terminal signal within 2000ms)
Test OK (HTTP Code: 200)
Test OK (actual value: Fallback product2)
Test OK (HTTP Code: 200)
Test OK (actual value: Fallback product2)
Test OK (HTTP Code: 404, {"httpStatus":"NOT_FOUND","message":"Product Id: 14 not found in fallback cache!","path":"/store/api/v1/products/14","timestamp":"2020-05-26@00:09:53.998+0000"})
...
Test OK (actual value: product name C)
Test OK (actual value: CLOSED)
Test OK (actual value: CLOSED_TO_OPEN)
Test OK (actual value: OPEN_TO_HALF_OPEN)
Test OK (actual value: HALF_OPEN_TO_CLOSED)
End, all tests OK: Tue, May 31, 2020 2:10:09 AM
Now, you can now track Microservices interactions throughout Zipkin UI from the following link:http://localhost:9411/zipkin/
Finally, to close the story, we need to shut down Microservices manually service by service, hahaha just kidding, run the following command to shut them all:
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ docker-compose -p ssm down --remove-orphans
And you should see output like the following:
Stopping ssm_recommendation_1 ... done
Stopping ssm_product_1 ... done
Stopping ssm_review_1 ... done
Stopping ssm_mongodb_1 ... done
Stopping ssm_store_1 ... done
Stopping ssm_auth-server_1 ... done
Stopping ssm_mysql_1 ... done
Stopping ssm_rabbitmq_1 ... done
Stopping ssm_eureka_1 ... done
Stopping ssm_gateway_1 ... done
Stopping ssm_config-server_1 ... done
Stopping ssm_zipkin_1 ... done
Removing ssm_recommendation_1 ... done
Removing ssm_product_1 ... done
Removing ssm_review_1 ... done
Removing ssm_mongodb_1 ... done
Removing ssm_store_1 ... done
Removing ssm_auth-server_1 ... done
Removing ssm_mysql_1 ... done
Removing ssm_rabbitmq_1 ... done
Removing ssm_eureka_1 ... done
Removing ssm_gateway_1 ... done
Removing ssm_config-server_1 ... done
Removing ssm_zipkin_1 ... done
Removing network ssm_default
In the end, I hope you enjoyed the application and find it useful, as I did when I was developing it.If you would like to enhance, please:
Happy Coding ...
Copyright (C) 2017-2020 Mohamed Taman, Licensed under the MIT License.
Store 就是用来维持应用所有的 state 树 的一个对象。 改变 store 内 state 的惟一途径是对它 dispatch 一个 action。 Store 不是类。它只是有几个方法的对象。 要创建它,只需要把根部的 reducing 函数 传递给 createStore。 Flux 用户使用注意 如果你以前使用 Flux,那么你只需要注意一个重要的区别。Redux 没有 Dispat
在前面的章节中,我们学会了使用 action 来描述 发生了什么,和使用 reducers 来根据 action 更新 state 的用法。 Store 就是把它们联系到一起的对象。Store 有以下职责: 维持应用的 state; 提供 getState() 方法获取 state; 提供 dispatch(action) 方法更新 state; 通过 subscribe(listener) 注册
当您的 M600连接到 Wi-Fi 网络时,您可以通过智能手表上的应用程式商店下载新的应用程式、游戏和时钟画面到您的 Wear OS by Google 智能手表上。 无论何时,只要您的 M600 上的Polar 应用程式有新的功能,您都可以通过 Play Store 商店下载更新信息。 您的 Polar M600 上需要有 Google 账户才能使用 Play Store 应用程式。如果您在设定
San 框架的官方应用状态管理套件,其理念是类似 flux 的单向流。 虽然应用状态管理已经是流行的理念,我们依然推荐您在开始之前,先看看 为什么要进行应用状态管理,可能会有些思考和启发。 提示:使用 san-store 需要同时使用 san-update 2.x 创建状态变更器,san-store 将使用此变更器更新 store 中的应用状态。 下载 NPM: $ npm i --save sa
通过此应用程序可享受在PlayStation®Store在线购买游戏或视频影像等商品的乐趣,也可下载游戏最新的免费体验版或宣传影片。 PS Store的LiveArea™ 关于PlayStation®Store 下载内容 下载视频影像 关于PlayStation®Store的付款方式 确认使用情况 再次下载内容
这是一个应用库,收录了优质的 Linux 应用 支持平台 Deepin 20 Ubuntu 20.04 LTS UOS Home 20 安装 可直接前往官网安装,releases界面有详细的安装说明 Deepin V20/UOS 系统下, 安装依赖 sudo apt install qt5-default libdtkcore-dev libdtkwidget-dev qtwebengine5-d