double.huang 737d3ebf05 feat: init | 3 years ago | |
---|---|---|
.. | ||
10月3日线上交流问题汇总.md | 3 years ago | |
API使用示例.md | 3 years ago | |
HTTP Middleware.md | 3 years ago | |
JWT生成.md | 3 years ago | |
JWT鉴权中间件.md | 3 years ago | |
README.md | 3 years ago | |
TraceHandler.md | 3 years ago | |
bloom.md | 3 years ago | |
bookstore-en.md | 3 years ago | |
bookstore.md | 3 years ago | |
executors.md | 3 years ago | |
goctl-api.md | 3 years ago | |
goctl-docker.md | 3 years ago | |
goctl-kube.md | 3 years ago | |
goctl-model.md | 3 years ago | |
goctl-overview.md | 3 years ago | |
goctl-plugin.md | 3 years ago | |
goctl-rpc.md | 3 years ago | |
goctl-template.md | 3 years ago | |
handler.md | 3 years ago | |
limit all.md | 3 years ago | |
logx.md | 3 years ago | |
model生成.md | 3 years ago | |
params.md | 3 years ago | |
periodlimit.md | 3 years ago | |
redis-lock.md | 3 years ago | |
rest engine.md | 3 years ago | |
router.md | 3 years ago | |
rpc调用.md | 3 years ago | |
server.md | 3 years ago | |
store all.md | 3 years ago | |
store mysql.md | 3 years ago | |
streamapi-fx.md | 3 years ago | |
timingWheel.md | 3 years ago | |
tokenlimit.md | 3 years ago | |
tokenparser.md | 3 years ago | |
zrpc客户端.md | 3 years ago | |
zrpc快速开始.md | 3 years ago | |
zrpc服务端.md | 3 years ago | |
zrpc目录结构.md | 3 years ago | |
zrpc简介.md | 3 years ago | |
中间件使用.md | 3 years ago | |
准备工作.md | 3 years ago | |
创建API服务.md | 3 years ago | |
功能描述.md | 3 years ago | |
参数配置客户端.md | 3 years ago | |
参数配置服务端.md | 3 years ago | |
开发指南.md | 3 years ago | |
快速开始.md | 3 years ago | |
拦截器.md | 3 years ago | |
服务注册.md | 3 years ago | |
流数据处理利器.md | 3 years ago | |
用户注册.md | 3 years ago | |
用户登陆.md | 3 years ago | |
自定义拦截器.md | 3 years ago | |
自定义错误返回.md | 3 years ago | |
自适应融断中间件.md | 3 years ago | |
获取用户信息(JWT鉴权).md | 3 years ago | |
获取用户信息(header).md | 3 years ago | |
负载均衡.md | 3 years ago | |
附录1.md | 3 years ago | |
附录2.md | 3 years ago | |
附录3.md | 3 years ago | |
项目创建.md | 3 years ago | |
验签中间件.md | 3 years ago |
go-zero是一个集成了各种工程实践的web和rpc框架。通过弹性设计保障了大并发服务端的稳定性,经受了充分的实战检验。
go-zero 包含极简的 API 定义和生成工具 goctl,可以根据定义的 api 文件一键生成 Go, iOS, Android, Kotlin, Dart, TypeScript, JavaScript 代码,并可直接运行。
使用go-zero的好处:
18年初,晓黑板后端在经过频繁的宕机后,决定从Java+MongoDB
的单体架构迁移到微服务架构,经过仔细思考和对比,我们决定:
对于微服务框架的设计,我们期望保障微服务稳定性的同时,也要特别注重研发效率。所以设计之初,我们就有如下一些准则:
我们经历不到半年时间,彻底完成了从Java+MongoDB
到Golang+MySQL
为主的微服务体系迁移,并于18年8月底完全上线,稳定保障了晓黑板后续增长,确保了整个服务的高可用。
go-zero是一个集成了各种工程实践的包含web和rpc框架,有如下主要特点:
如下图,我们从多个层面保障了整体服务的高可用:
在项目目录下通过如下命令安装:
GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero
goctl
读作go control
,不要读成go C-T-L
。goctl
的意思是不要被代码控制,而是要去控制它。其中的go
不是指golang
。在设计goctl
之初,我就希望通过她
来解放我们的双手👈GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go get -u github.com/tal-tech/go-zero/tools/goctl
确保goctl可执行
goctl api new greet
cd greet
go run greet.go -f etc/greet-api.yaml
默认侦听在8888端口(可以在配置文件里修改),可以通过curl请求:
curl -i http://localhost:8888/from/you
返回如下:
HTTP/1.1 200 OK
Date: Sun, 30 Aug 2020 15:32:35 GMT
Content-Length: 0
编写业务代码:
goctl api java -api greet.api -dir greet
goctl api dart -api greet.api -dir greet
...
go-zero背后的思考,从整体上来理解微服务系统设计: https://www.bilibili.com/video/BV1rD4y127PD/