{"id":21018701,"url":"https://github.com/tal-tech/gaea","last_synced_at":"2025-05-15T06:31:43.705Z","repository":{"id":56327594,"uuid":"282787190","full_name":"tal-tech/gaea","owner":"tal-tech","description":" Gaea is a Gin-based web framework, reference gin https://github.com/gin-gonic/gin","archived":false,"fork":false,"pushed_at":"2020-10-29T13:17:54.000Z","size":147,"stargazers_count":120,"open_issues_count":0,"forks_count":30,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-03T05:12:19.766Z","etag":null,"topics":["api","gin","go","http-server","rpc-client","web-framework"],"latest_commit_sha":null,"homepage":"https://www.yuque.com/tal-tech/gaea","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tal-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-27T03:42:22.000Z","updated_at":"2024-06-18T09:52:30.000Z","dependencies_parsed_at":"2022-08-15T16:40:52.241Z","dependency_job_id":null,"html_url":"https://github.com/tal-tech/gaea","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tal-tech%2Fgaea","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tal-tech%2Fgaea/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tal-tech%2Fgaea/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tal-tech%2Fgaea/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tal-tech","download_url":"https://codeload.github.com/tal-tech/gaea/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254288235,"owners_count":22045863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","gin","go","http-server","rpc-client","web-framework"],"created_at":"2024-11-19T10:27:10.009Z","updated_at":"2025-05-15T06:31:41.448Z","avatar_url":"https://github.com/tal-tech.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 简介\n\u003cp align=\"center\"\u003e\n \u003ca href=\"https://tal-tech.github.io/gaea-doc/\" target=\"_blank\"\u003e\n     \u003cimg src=\"https://i.ibb.co/PN1rS28/11.png?raw=true\"  alt=\"Gaea Logo\" align=center /\u003e\n \u003c/a\u003e \n\u003c/p\u003e\n\nGaea是一基于`Gin`的Web框架。 在实际工作中，在将项目应用于生产环境之前，还需要解决一系列其他工程问题,\n否则，系统的可移植性将很差，并且开发人员将无法专注于业务开发。\n集成到一套完整的解决方案中：依赖关系管理，配置管理，编译和部署，监视和警报，并支持一键式快速构建Web应用程序。 如果您正在考虑用Golang编写Web服务器，那么Gaea无疑是您的最佳选择！\n## Document\n[Documentation](https://tal-tech.github.io/gaea-doc)\n\n[中文文档](https://www.yuque.com/tal-tech/gaea)\n\n\n## 安装\n\n### 安装脚手架\n通过 [rigger](https://github.com/tal-tech/rigger)脚手架可一键创建Gaea模板的api项目\n\n### 生成框架\n\n此处以\"myproject\"为项目名称\n```shell\n$ rigger new api myproject\n正克隆到 '/winshare/go/src/myproject'...\nmyprojec项目已创建完成, 使用:\n cd /winshare/go/src/myproject \u0026\u0026 rigger build \n\n```\n\n\n### 编译\n\n```golang\n//Will use makefile to compile and generate binary files to the bin directory\n$ cd gaea\n$ make\n```\n\n### help\n```go\n$ ./bin/myproject --help\nUsage of ./bin/myproject:\n  -c string\n    \t指定ini配置文件，以程序的二进制文件(myproject)为相对目录，正确的相对目录加载方式： -c ../conf/conf_xxx.ini； 默认为加载 ../conf/conf.ini\n  -p string\n        配置文件的前缀设置，用于以绝对路径形式加载，如  -c conf.ini -p /usr/pathto/myproject/conf\n  -cfg string\n    \tjson config path (default \"conf/config.json\")\t\t\n  -extended string\n    \t扩展参数，程序未定义使用用途，用户可自行处理\n  -f\tforeground\n  -m\tmock 开关\t\n  -s string\n    \tstart or stop\n  -usr1 string\n    \tuser defined flag -usr1\n  -usr2 string\n    \tuser defined flag -usr2\n  -usr3 string\n    \tuser defined flag -usr3\n  -usr4 string\n    \tuser defined flag -usr4\n  -usr5 string\n    \tuser defined flag -usr5\n  -v\tversion\n```\n\n## Example\n1.Config server port\n```golang\n//conf/conf.ini\n[Server]\n;Gin启动的模式,可选debug/release\nmode=debug\n;http server 监听端口\naddr=:9898\n;是否开启平滑重启\ngrace=true\nreadTimeout=3s\nwriteTimeout=3s\n;...\n```\n\n2.Add router\n```golang\n//app/router/router.go is the file that manage all URI\nfunc RegisterRouter(router *gin.Engine) {\n\tentry := router.Group(\"/demo\", middleware.PerfMiddleware(), middleware.XesLoggerMiddleware())\n\tentry.GET(\"/test\", democontroller.GaeaDemo)\n}\n```\n\n4.Controller (mvc programming style)\n```golang\n//app/router/\nfunc GaeaDemo(ctx *gin.Context) {\n\tgoCtx := xesgin.TransferToContext(ctx)\n\tparam := ctx.PostForm(\"param\")\n\tret, err := demoservice.DoFun(goCtx, param)\n\tif err != nil {\n\t\tresp := xesgin.Error(err)\n\t\tctx.JSON(http.StatusOK, resp)\n\t} else {\n\t\tresp := xesgin.Success(ret)\n\t\tctx.JSON(http.StatusOK, resp)\n\t}\n}\n```\n\n### 运行\n```go\n$ rigger start\n2019/11/06 21:50:03 CONF INIT,path:../conf/conf.ini\n[GIN-debug] [WARNING] Running in \"debug\" mode. Switch to \"release\" mode in production.\n - using env:    export GIN_MODE=release\n - using code:    gin.SetMode(gin.ReleaseMode)\n\n[GIN-debug] GET    /demo/test                --\u003e myproject/app/controller/democontroller.MyXesGoDemo (3 handlers)\n2019/11/06 21:50:03 [overseer master] run\n2019/11/06 21:50:04 [overseer master] starting /winshare/go/src/myproject/bin/myproject\n2019/11/06 21:50:04 CONF INIT,path:../conf/conf.ini\n[GIN-debug] [WARNING] Running in \"debug\" mode. Switch to \"release\" mode in production.\n - using env:    export GIN_MODE=release\n - using code:    gin.SetMode(gin.ReleaseMode)\n\n[GIN-debug] GET    /demo/test                --\u003e myproject/app/controller/democontroller.MyXesGoDemo (3 handlers)\n2019/11/06 21:50:04 [overseer slave#1] run\n2019/11/06 21:50:04 [overseer slave#1] start program\n```\n\n### 测试\n```go\n$ curl  http://127.0.0.1:9898/demo/test\n{\"code\":0,\"data\":{\"ret1\":\"Welcome to use myproject!\"},\"msg\":\"ok\",\"stat\":1}\n```\n\n----------\n至此，我们已经通过Gaea搭建了一个web服务！\n接下来我们进一步学习Gaea 相关配置、特性、组件应用等主题\n\n\n## 各大主流框架路由性能对比\n\n\u003cp align=\"center\"\u003e\n \u003ca href=\"https://tal-tech.github.io/gaea-doc/\" target=\"_blank\"\u003e\n     \u003cimg src=\"https://i.ibb.co/TB64zTd/jianjie-xingneng.png\"  alt=\"Gaea Logo\" align=center /\u003e\n \u003c/a\u003e \n\u003c/p\u003e\n\n\n(图片来自于网络)\n\n\n### Gaea性能压测\nGaea框架相比于原生Gin 影响性能的点其实是全部集中在中间件上，因为每次http请求都会跑一边，所以，观测下在各个中间开启时对整体性能的影响情况\n### 压测条件\n\n| 条件 |  值 |\n| ---- | ---- |\n| 系统 |  virtualbox 虚拟机上 centos7 |\n| 内存| 1GB |\n|CPU| 单核|\n|请求数量| 10万|\n|并发数量|100|\n|传输数据|{\"code\":0,\"data\":\"hell world\",\"msg\":\"ok\",\"stat\":1}|\n \n### 压测结果\n\n\u003cp align=\"center\"\u003e\n \u003ca href=\"https://tal-tech.github.io/gaea-doc/\" target=\"_blank\"\u003e\n     \u003cimg src=\"https://i.ibb.co/Wyjr9Zs/perf.png\"  alt=\"Gaea Logo\" align=center /\u003e\n \u003c/a\u003e \n\u003c/p\u003e\n\n从图中我们可以明显看出：\n* Gaea的默认配置会带来一定的性能耗损，大约30%\n* 其中`Logger`中间件在各个中间件影响性能比重最大，其它中间件几乎可以忽略不计\n\n在实际项目应用中，当`Logger` 中间件是瓶颈点时，我们可以关闭它，毕竟请求日志在网关层也会记录！\n\n此外，对[日志库](https://github.com/tal-tech/loggerX)使用建议日志级别设定为`WARNING`\n\n\n## 联系我们\n\u003cp align=\"left\"\u003e\n \u003ca href=\"https://tal-tech.github.io/gaea-doc/\" target=\"_blank\"\u003e\n     \u003cimg src=\"https://cdn.nlark.com/yuque/0/2020/png/2138318/1600340932767-f20251e4-688a-4077-9721-9296f5319e56.png\"  alt=\"Contact Us\" align=center /\u003e\n \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"left\"\u003e\n（微信扫一扫，申请加入开发讨论微信群）\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftal-tech%2Fgaea","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftal-tech%2Fgaea","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftal-tech%2Fgaea/lists"}