Project Icon

go-zero-looklook

go-zero微服务实践项目

go-zero-looklook是一个基于go-zero框架的微服务实践项目,旨在提供完整的开发示例。项目集成了k8s、nginx网关、kafka、elasticsearch等技术,实现了日志处理、监控、链路追踪和消息队列等功能。它提供详细文档、架构图以及Docker Compose开发环境,同时支持k8s部署,为开发者学习和实践go-zero提供了全面参考。

go-zero-looklook

English | 简体中文

Summary

The old rule is to give a star before you see it. Ha ~ ~, if the star is caught, you have to spank, ha ha

I may have contacted go zero earlier. I have been using go zero since about 1000star. Later, I became familiar with the go zero author through wechat. The go zero author was very enthusiastic and patient to help me answer many questions. I also want to actively help go zero promote the community, Basically, I answered the relevant questions in the community group, because in this process, I found that many people felt that go zero did not have a complete project example. As a member of the community who wanted to promote the community, I made an available version open source. The main technology stack includes the following:

Tips : If you are unfamiliar with the technologies in the current stack, don't worry. Simply start by mastering MySQL and Redis. Begin your project by running these two middleware components, and gradually expand your knowledge of the remaining technologies as you progress.
  • k8s
  • go-zero
  • nginx-gateway
  • filebeat
  • kafka
  • go-stash
  • elasticsearch
  • kibana
  • prometheus
  • grafana
  • jaeger
  • go-queue
  • asynq
  • asynqmon
  • dtm
  • docker
  • docker-compose
  • mysql
  • redis
  • modd
  • jenkins
  • gitlab
  • harbor

Tutorial video

This is the go zero tutorial I'm recording :https://space.bilibili.com/389552232/video

At the end of this tutorial, we will also share go-zero -looklook. Please look forward to it~

Doc

Documentation can de found under doc/english in the project.

Docker compose is recommended in the development environment of the project. The direct chain method is used to give up the trouble caused by service registration and discovery middleware (etcd, nacos, consul ...)

For testing and online deployment, k8s (etcd, Nacos, consumer, etc.) has detailed tutorials (build + deploy), which can be communicated in the go zero community group, which is very easy

Project Summary

The whole project uses the micro services developed by go zero, which basically includes go zero and some middleware developed by relevant go zero authors. The technology stack used is basically the self-developed component of the go zero project team, which is basically the go zero software

The project directory structure is as follows:

  • app:All business codes include API, RPC and MQ (message queue, delay queue, scheduled task)

  • common:General components ( error、middleware、interceptor、tool、ctxdata ...)

  • data:The project contains the data generated by the directory relying on all middleware (mysql, ES, redis, grafana, ...). All contents in this directory should be in Git ignore files and do not need to be submitted.

  • deploy:

    • filebeat: docker deployment filebeat config
    • go-stash:go-stash config
    • nginx: nginx-gateway config
    • prometheus : prometheus config
    • script:
      • gencode:auto generate api、rpc,and use kafka script ,copy and paste use
      • mysql:auto generate model code shell script
    • goctl: The template and goctl of the project generate custom code templates. For the usage of template, refer to the go zero document and copy it to the home directory Goctl is enough
  • doc : This project series documents

  • modd.conf : Don't be afraid of Modd hot loading configuration file. It's very simple to use. You can learn more about Modd usage here: https://github.com/cortesi/modd , the image of this project only uses golang-1.17.7-alpine as the basic image and installs Modd internally. If you want to add goctl, protoc, golint, etc., it's the same to directly create an image without my image

System architecture diagram

jiagou

Business architecture diagram

jiagou

Gateway

nginx do external gateway, gateway in front of the slb, in addition, many students feel that nginx do not do gateway is not very good, this piece of principle is basically the same, you can replace it with apisix, kong, etc.

Development mode

This project uses microservice development, API (HTTP) + RPC (grpc). The API acts as an aggregation service, and the complex and related business calls are uniformly written in RPC. If some simple businesses will not be relied on by other services, they can be directly written in the logic of API

Log

For logs, filebeat is used to collect them and report them to Kafka. Because logstash knows everything and the resource occupation is too exaggerated, go stash is used instead of logstash

Link: https://github.com/kevwan/go-stash , go stash is developed by the go zero development team. It has high performance and does not occupy resources. There is not much main code. It can be used only by configuration. It is very simple. The Kafka data source is synchronized to elasticsearch. The elasticsearch account and password are not supported by default. I fork a copy and modify it. It simply supports the account and password

Monitor

Prometheus is used for monitoring. This go zero native support only requires configuration. Here you can see the configuration in the project

Link tracking

Go zero supports Jaeger and Zipkin by default. You only need to configure it. You can see the configuration

Pub\Sub

kafka ,Publish subscription using go-zero development team developed by go-queue, link: https://github.com/zeromicro/go-queue

Here we use kq, kq is based on kafka to do high-performance publish subscriptions

Message queues, delayed queues, timed tasks

Message queues, delay queues, timed tasks This project uses asynq, a simple middleware developed based on redis.

Of course, the message queue you can also use go-queue

Link: https://github.com/hibiken/asynq

Distributed transaction

DTM is used for distributed transactions. Well, it's very comfortable. I wrote a "go zero nanny tutorial on connecting distributed transactions with DTM" link address: https://github.com/Mikaelemmmm/gozerodtm , this project has not been used yet. It's good to prepare for direct integration in the future. If readers use it, they can directly look at the source code

Dtm Link : https://github.com/dtm-labs/dtm

Deploy

Docker compose is recommended in the development environment of the project. The direct chain method is used to give up the trouble caused by service registration and discovery middleware (etcd, Nacos, consul, ...)

For testing and online deployment, k8s (etcd, Nacos, consumer, etc.) has detailed tutorials (build + deploy), which can be communicated in the go zero community group, which is very easy

project doc :https://github.com/Mikaelemmmm/go-zero-looklook/tree/main/doc

gitlab + jenkins + harbor + k8s

Click in jenkins to deploy the corresponding service, will go to gitlab to pull the code --> then go to pull the online configuration (online configuration of a separate git repository, why not use the configuration center, the deployment documentation has an introduction) ----> automatically build the image --> push to harbor mirror repository --> use kubectl to automatically publish to k8s ----> in front to hang a nginx do gateway unified portal

Thanks

go-zero : https://github.com/zeromicro/go-zero

dtm:https://github.com/dtm-labs/dtm

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号