同步操作将从 DoubleJin/jin-microservices 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
English | 中文
Jin microservices is a complete microservice demo based on PHP language + hyperf microservices framework
github:https://github.com/Double-Jin/jin-microservices
gitee:https://gitee.com/ljj96/jin-microservices
As a developer of both php and go, the microservice system of the go language has been basically mastered. There are a lot of articles and open source projects related to the go language on the Internet, which makes it easy for developers who know the go language Get started and implement microservices. After all, go language is the most suitable language for microservices other than java.
The advantage of the php language lies in the web ecosystem, and most of the applications developed are monolithic application architectures. In recent years, with the emergence of hyperf framework based on swoole extension, php can also develop microservice architecture, thanks to open source workers. However, when using "php + microservices" as the keyword, the articles and open source projects searched are simple cases. Developers cannot understand microservices through these simple cases, which makes me want to write this project. raw power.
JM is a complete microservice demo written based on php language + hyperf microservice framework. Unlike articles that can be found on the Internet with simple implementation of a single function point, JM starts from the actual project requirements and strives to achieve the git clone project. The file can help you build a complete knowledge system for microservices, so that you can paste and copy the code of this project when you actually use hyperf to develop a microservice project.
The microservice architecture is not an architecture that is more advanced than the monolithic architecture, but a choice after the project volume and the number of project developers reach a certain order of magnitude. Do not blindly advocate microservices. Forcibly promoting the microservice architecture when the team's development and operation and maintenance capabilities are insufficient may be counterproductive.
The components mentioned below are not only used in microservice architecture, such as elk, nacos, and dtm. They are also used in suitable scenarios in monolithic applications, and the essence of them can be used to meet business needs. If these components are used in production, it is best to choose to compile and install or purchase cloud services
Microservices are an architecture that splits a monolithic application. By using third-party components to solve the problems caused by the split, you will encounter many strange problems when installing and deploying these components. In order to reduce the difficulty, most of the components of this project are installed by docker. I have verified the overall process several times on different computers. Even so, there are still problems such as composer, github, http/tcp access, ports, memory, docker version, etc. , the same operation may cause problems if you change the computer, which requires you to find relevant information according to the content of the error to solve it yourself.
Directory Structure
|-- api-gateway //Gateway service project code
|-- order-srv //Order service project code
|-- user-srv // User service project code
|-- task-srv // Timed task and queue service project code
|-- doc // Documentation directory
|-- README.md //English description
|-- README-CN.md //Chinese description
Complete microservice architecture
JsonRpc call
GET http://127.0.0.1:9501/User/UserInfo
Communication single serviceGET http://127.0.0.1:9501/User/UserBonusList
Communication single serviceGET http://127.0.0.1:9501/User/UserStoredList
Communication single serviceGET http://127.0.0.1:9501/Order/OrderList
Communication multiple servicesJwt authority authentication
GET http://127.0.0.1:9501/Auth/Login
User loginGET http://127.0.0.1:9501/Auth/Logout Authorization : Bearer {{token}}
User logged outUpload the file
POST http://127.0.0.1:9501/File/UploadFile
The file is converted to a base64 string and transferred via json-rpcfile-srv.app.JsonRpc.FileRpcService.uploadFile
Generate a file by receiving a base64 string via json-rpcUnified exception handling
Service Registration and Service Discovery
Message queue
GET http://127.0.0.1:9501/User/UserRabbitMQ
Call the delivery user message queue interfaceGET http://127.0.0.1:9501/Order/OrderRabbitMQ
Call the delivery order message queue interface
Link tracking
Configuration Center
Service current limit
GET http://127.0.0.1:9501/RateLimit/Test
Service downgrade
GET http://127.0.0.1:9501/CircuitBreaker/Test
Distributed log
When the system becomes a cluster, the application logs on dozens or even hundreds of different servers can realize the functions of unified search, analysis and archiving of logs, which can be called a distributed log system.
There are many solutions in production, such as outputting logs directly to Elasticsearch, such as using log collection provided by cloud service providers. In this case, the log is synchronized to ELK through filebeat.
Distributed transaction
A database transaction ensures that all operations within the scope of the transaction can either succeed or fail. But for distributed systems, data operations come from multiple different databases, and the success or failure of a single database transaction does not mean that the data consistency of the entire system is correct, and can only be resolved through distributed transactions.
Distributed transaction means that the initiator, resource and resource manager and transaction coordinator of the transaction are located on different nodes of the distributed system. Two-phase submission, SAGA, TCC and other schemes are commonly used in the industry. After understanding the principle, you can also use http/tcp to achieve two-phase submission, SAGA, and TCC.
The following interface is implemented in a SAGA case via DTM scheduling.
POST http://127.0.0.1:9501/Order/CreateOrder
Distributed transaction
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。