Develop a travel system using go-zero go-zero-looklook

Using go-zero to develop a travel system go-zero-looklook#

The go-zero author is very enthusiastic and patient to help me answer a lot of questions, I also want to actively help go-zero to promote the community. -zero to promote the community, basically in the community group to answer questions related to everyone, because in this process found that many people feel go-zero does not have a complete project example, as a member of the community want to promote, so I will be internal project to delete some key things, on the engage a available version of open source out, the main technology stack contains the following.

  • go-zero
  • nginx gateway
  • filebeat
  • kafka
  • go-stash
  • elasticsearch
  • kibana
  • prometheus
  • grafana
  • jaeger
  • go-queue
  • asynq
  • asynqmon
  • docker
  • docker
  • docker-compose
  • mysql
  • redis

Project address#

Project documentation#

Project Introduction#

The whole project uses go-zero development of microservices, basically contains go-zero and related go-zero author development of some middleware, the technology stack used is basically go-zero project team of self-research components, basically go-zero family bucket In addition, the front-end is a small program, the project has been docked to the small program authorization login and WeChat payment, front-end to see if the open source it later

The project directory structure is as follows.

  • app: all business code including api, rpc and mq (message queue, delay queue, timing tasks)

  • common: common components error, middleware, interceptor, tool, ctxdata , etc.

  • data: This project contains the data generated by the directory dependency on all middleware (mysql, es, redis, grafana, etc.), all the content in this directory should be in the git ignore file, no need to commit.

  • deploy.

    • filebeat: docker deployment filebeat configuration
    • go-stash: go-stash configuration
    • nginx: nginx gateway configuration
    • prometheus : prometheus configuration
    • script.
      • gencode: generate api, rpc, and create kafka statements, copy and paste to use
      • mysql: sh tool for generating mods
    • goctl: the project goctl template, goctl generate custom code templates, tempalte usage can refer to go-zero documentation, copy to the home directory . The project uses goctl version is v1.2.3
  • doc : the project series documentation

System architecture diagram#


Business architecture diagram#



nginx do gateway, use nginx auth module, call the back-end identity service unified authentication, business internal authentication is not, if it involves more business funds can also be in the business of secondary authentication, in order to security well.

In addition, many students feel that nginx is not a good gateway, the principle of this piece is basically the same, you can replace it with apisix, kong, etc.

development model#

The project uses microservice development, api (http) + rpc (grpc), api act as an aggregation service, complex, involving other business calls written in the rpc, if some simple business will not be used by other service dependencies, you can write directly in the api's logic


About the log, unified use filebeat collection, reported to kafka, because logstash know all understand, resource consumption is too exaggerated, here used go-stash to replace the logstash

Link: , go-stash is developed by the go-zero development team, high performance does not take up resources, the main amount of code is not much, you only need to configure it can be used, very simple. It is bar kafka data source synchronization to elasticsearch, the default does not support elasticsearch account password, I forked a copy of the modified, very simple to support the account, password


monitoring using prometheus, this go-zero native support, just need to configure it, here you can see the configuration of the project

link tracking#

go-zero default jaeger, zipkin support, just need to configure it, you can see the configuration

Message queue#

message queue using go-zero development team developed by go-queue, link:

Here you can use kq, kq is based on kafka to do high-performance message queue

generic go-queue also has dq, is a delayed queue, but the current project does not use dq

Delayed queues, timed tasks#

delayed queue, timing tasks this project is using asynq, google team to give redis development of simple middleware.

Of course, asynq also supports message queues, you can also replace the kq message queue into this, after all, only need redis does not need to maintain a kafka is also good


Distributed Transactions#

distributed transactions ready to use is dtm, well , very comfortable, before I wrote a "go-zero docking distributed transactions dtm nanny tutorial" Link: , the project is not currently used to, the follow-up is ready to integrate directly on the good, if readers use directly to Look at that source code on the line


Deployment, the current direct use of docker can deploy the entire technology stack, if the k8s words, the simplest direct use of Ali cloud it

I say the next idea, this follow-up will come out of an Ali cloud effect based on the deployment to k8s documentation tutorials, build a gitlab, jenkins, harbor to do if too time-consuming

1, the code will be placed in the Ali cloud effect (of course you whole to gitlab is also OK)

2, in the Ali cloud effect to create a pipeline, basically a service a pipeline

3, pipeline steps :)

pull code ---> ci detection (here you can omit ha, do it yourself) ---> build the image (go-zero official Dockerfile and tutorials, don't tell me won't) ---> push to Ali cloud mirror service ---> use kubectl to Ali cloud k8s pull mirror (ack, ask can, ask can not use daemonset can not be used. ask can't use daemonset can't use filebeat) ---->ok

In addition, if you want to do it yourself based on gitlab, jenkins, harbor, then, well, find your own operations and maintenance to get it, I have written a tutorial before, free in the whole bar old brothers!

Last updated on