• Stars
    star
    192
  • Rank 200,913 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 2 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

gin+grpc+gorm+etcd+mysql 的备忘录功能。Gin作为HTTP的web框架,gRPC作为RPC框架,ETCD作为服务注册与发现。

gRPC-todoList

gin+grpc+gorm+etcd+mysql 的备忘录功能

注意

V2版本和v1版本的项目结构改变很大。

项目主要依赖

  • gin
  • gorm
  • etcd
  • grpc
  • jwt-go
  • logrus
  • viper
  • protobuf

项目结构

1.grpc_todolist 项目总体

grpc-todolist/
├── app                   // 各个微服务
│   ├── gateway           // 网关
│   ├── task              // 任务模块微服务
│   └── user              // 用户模块微服务
├── bin                   // 编译后的二进制文件模块
├── config                // 配置文件
├── consts                // 定义的常量
├── doc                   // 接口文档
├── idl                   // protoc文件
│   └── pb                // 放置生成的pb文件
├── logs                  // 放置打印日志模块
├── pkg                   // 各种包
│   ├── e                 // 统一错误状态码
│   ├── discovery         // etcd服务注册、keep-alive、获取服务信息等等
│   ├── res               // 统一response接口返回
│   └── util              // 各种工具、JWT、Logger等等..
└── types                 // 定义各种结构体

2.gateway 网关部分

gateway/
├── cmd                   // 启动入口
├── internal              // 业务逻辑(不对外暴露)
│   ├── handler           // 视图层
│   └── service           // 服务层
│       └── pb            // 放置生成的pb文件
├── logs                  // 放置打印日志模块
├── middleware            // 中间件
├── routes                // http 路由模块
└── rpc                   // rpc 调用

3.user && task 用户与任务模块

user/
├── cmd                   // 启动入口
└──internal               // 业务逻辑(不对外暴露)
   ├── service            // 业务服务
   └── repository         // 持久层
       └── db             // 视图层
           ├── dao        // 对数据库进行操作
           └── model      // 定义数据库的模型

项目完善

🎈最新版本是 v2 ,欢迎大家将自己的想法pr到版本对应分支,CR通过后,我们将合并到main分支。

  • 添加熔断机制
  • ....其他想法

项目文件配置

config/config.yml文件,直接将 config.yml.example-->config.yml 就可以了

server: # 项目配置
  port: :4000 # 项目端口
  version: 1.0 
  jwtSecret: 38324

mysql: # mysql相关配置
  driverName: mysql
  host: 127.0.0.1
  port: 3306
  database: grpc_todolist
  username: grpc_todolist
  password: grpc_todolist
  charset: utf8mb4

redis: # redis相关配置,其实没有用到redis...
  user_name: default
  address: 127.0.0.1:6379
  password:

etcd: # etcd相关配置
  address: 127.0.0.1:2379

services: # 各个微服务的配置
  gateway:
    name: gateway
    loadBalance: true
    addr:
      - 127.0.0.1:10001
  user:
    name: user
    loadBalance: false
    addr:
      - 127.0.0.1:10002 # user模块地址
  task:
    name: task
    loadBalance: false
    addr:
      - 127.0.0.1:10003 # task模块地址

domain:
  user:
    name: user
  task:
    name: task

项目启动

makefile启动

启动命令

make env-up         # 启动容器环境
make user           # 启动用户摸块
make task           # 启动任务模块
make gateway        # 启动网关
make env-down       # 关闭并删除容器环境

其他命令

make proto # 生成proto文件,如果proto有改变的话,则需要重新生成文件

生成.pb文件所需要的工具有protoc-gen-go,protoc-gen-go-grpc,protoc-go-inject-tag

手动启动

  1. 利用compose快速构建环境
docker-compose up -d
  1. 保证mysql,etcd活跃, 在 app 文件夹下的各个模块的 cmd 下执行
go run main.go

导入接口文档

打开postman,点击导入

postman导入

选择导入文件 选择导入接口文件

导入

效果

postman

More Repositories

1

gin-mall

基于 gin+gorm+redis+mysql 读写分离的电子商城,包括 JWT 鉴权,CORS跨域,AES 对称加密,引入ELK体系方便日志查看,jaeger进行trace查看,skywalking进行检测,使用docker容器化部署
Go
484
star
2

TodoList

Gin+Gorm+Redis+Swagger 基于 RESTful API 规范搭建备忘录,包括redis缓存,swagger文档,docker部署
Go
197
star
3

micro-todoList

Go语言微服务实战,go-micro+gin+gorm+rabbitMQ 构造简单备忘录,包括ETCD作为服务发现,JWT鉴权,降级熔断等等
Go
138
star
4

gin-chat-demo

gin+websocket+mongodb实现 IM 即时聊天系统,基于WS连接的即时聊天,支持单聊,在线回复以及历史记录查询
Go
119
star
5

Golang-Learning

以本人为例,学习Go语言的路线。我也是从20年10月开始接触go语言,和大家分享一下我的学习路程。
Go
114
star
6

tangseng

Tangseng search engine including full text search and vector search base on golang. 基于go语言的搜索引擎,信息检索系统
Go
111
star
7

Golang-Interview

记录实习、秋招中大型公司的Go语言面经,包括字节跳动,腾讯,滴滴,百度等等...内容涉及Go的基础语法以及底层,数据结构与算法,操作系统,数据库,计算机网络,计算机组成原理等等.....
56
star
8

BiliBili

Gin框架实现B站,Gin+Gorm 实现一个视频弹幕网站
Go
34
star
9

TeenStudy

青年大学习一键提醒、福建省,安徽省,上海市都有
Python
27
star
10

Go-SecKill

Gin+Gorm+Redis+ETCD的秒杀系统,列举出一系列并发情况下数据竞争问题的解决方案。
Go
26
star
11

Go-Spider-Demo

使用go语言进行爬虫的小案例
Go
25
star
12

gesture-recognizion

YOLO+ResNet的手势识别,YOLO进行目标识别,ResNet进行特征提取
Python
24
star
13

Lottery

以太坊智能合约实战 —— FanOne彩票网
Smarty
22
star
14

Car-Manage-System

Gin + Gorm 实现车辆信息联络平台
Go
17
star
15

BiliBili-Word

BiliBili 科普文案
11
star
16

react-todolist

typescript + react + antd + axios + redux 进行简单备忘录的构建
JavaScript
10
star
17

react-mall

gin-mall商城前端
TypeScript
8
star
18

go-plus-demo

使用go+进行爬虫并数据处理
Go
6
star
19

FaceYOLOv5

基于YOLOv5的人脸检测
Python
6
star
20

Car-Mini-Program

车辆信息联络平台的小程序端
JavaScript
6
star
21

secret

Provide the interface of symmetric encryption AES/DES/3DES and asymmetric encryption RSA, making your sensitive data easier to desensitize and store.( 提供 对称加密 AES/DES/3DES 以及非对称加密 RSA 的上层封装接口,让您的敏感数据更加容易脱敏并存储 )
Go
6
star
22

go-html2image

HTML to image tool based on golang
Go
5
star
23

Net-Demo

Go 语言实现TCP,UDP通信等等
Go
5
star
24

Python_Spider_demo

Python
5
star
25

NumpyMnist

纯Numpy实现手写数字识别
Jupyter Notebook
4
star
26

ML-Projects

记录机器学习的笔记
Python
4
star
27

Car-Yolo-FasterRcnn

Python
4
star
28

Flask_pandown

this is a wangpan of flask eduction
Python
4
star
29

PlantsVsZooms

Python
4
star
30

WxSnakeRush

JavaScript
4
star
31

mq-server

rabbitmq 服务端
Go
4
star
32

gRPC-Demo-Test

关于gRPC的一些小demo
Go
4
star
33

Gin-Seckill

基于Gin框架的商品秒杀系统
4
star
34

CocaineCong

4
star
35

FaceYOLOv3

基于YOLOv3的人脸检测算法
Python
4
star
36

react-tangseng

搜索引擎前端
JavaScript
4
star
37

eslogrus

an es hook base golang for logrus. 一个基于go语言的es钩子,为了能把logrus的日志送到es
Go
3
star
38

MIT6.824

for mit 6.824 knowledge learning
3
star
39

fgen

基于 gorm 根据数据库自动生成 curd 模版
Go
2
star
40

BiliBili-Code

b站的demo代码
HTML
2
star
41

mysql2other

Sync MySQL data into elasticsearch
Go
2
star
42

ChatRoom

使用go写的一个聊天室
JavaScript
1
star
43

gosin

kv store
1
star
44

fenbi

Kotlin
1
star
45

react-todolist-js

JavaScript
1
star