Before we can actually create the project, we need to rethink the division of services.
I named the project FoodGuides
The FoodGuides project has two main functions, userManage and FoodManage.
Analyze user management userManage
Usermanage also has two blocks of services, API service and RPC service.
The API service needs to provide three API interfaces.
login
: user login interfaceregister
: user registration interfaceuserinfo
: User information interface
The RPC service needs to provide three interfaces.
login
: user login interfaceregister
: user registration interfaceuserinfo
: User information interface
Although the two services provide the same functions, we need to distinguish the service objects of the two services. The API service is external. For example, app invokes the API service here. RPC services are internal, such as API services that invoke RPC services.
- If the
foodguides
Like a restaurant, that’sapi
The service is like a waiter,rpc
The service is like a chef. - The waiter serves the guest directly. The guest can ask the waiter and say I want a satay noodle. (
app
The client calledapi
servicelogin
Interface) - The chef serves the service staff and tells the chef to order a satay noodle after receiving the guest’s order. (
api
servicelogin
Interface calledrpc
servicelogin
Interface) - The chef makes the satay noodles and hands them to the waiter, who then brings the dishes to the guests. This completes an order. (
rpc
servicelogin
The interface responds after processing the dataapi
servicelogin
Interface,api
servicelogin
The interface responseapp
Client call, login successful)
This completes a service invocation.
The same goes for food management FoodManage. The existing level of understanding makes it easier for beginners to figure out the project structure.
Project creation
Create a project in Coding, select the DevOps template, and name it FoodGuides
In the FoodGuides project, select the code repository and create a new code repository named FoodGuides
In the FoodGuides project, select Articles Management – Articles Warehouse, create a new articles warehouse, type Docker, and name the warehouse address DockerImages.
In the FoodGuides project, select the repository, copy the Git address in the repository Settings, and clone it locally.
CD to the FoodGuides
go mod init FoodGuides
Copy the code
Create two folders in FoodGuides
mkdir -p usermanage & mkdir -p foodmanage
Copy the code
So we basically completed the creation of the project.
The go-Zero Tutorial — Tool Download and Environment Setup
The next go-Zero tutorial — User Management API Gateway