From 893d02bed50b31030a31d71b4593894cf81d2cce Mon Sep 17 00:00:00 2001 From: EpicMo <1982742309@qq.com> Date: Sat, 2 Sep 2023 09:21:48 +0800 Subject: [PATCH 1/2] feat: user rate limit --- src/web/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/web/main.go b/src/web/main.go index 74128d0..ab91431 100644 --- a/src/web/main.go +++ b/src/web/main.go @@ -21,6 +21,7 @@ import ( "github.com/sirupsen/logrus" ginprometheus "github.com/zsais/go-gin-prometheus" "go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin" + "time" ) func main() { @@ -49,7 +50,7 @@ func main() { // Configure Tracing g.Use(otelgin.Middleware(config.WebServiceName)) g.Use(middleware.TokenAuthMiddleware()) - //g.Use(middleware.RateLimiterMiddleWare(time.Second, 10000, 10000)) + g.Use(middleware.RateLimiterMiddleWare(time.Second, 1000, 1000)) // Configure Pyroscope profiling.InitPyroscope("GuGoTik.GateWay") From ce2524e3f76217d16099b521c6a29737fb9ed742 Mon Sep 17 00:00:00 2001 From: EpicMo <1982742309@qq.com> Date: Sat, 2 Sep 2023 10:06:36 +0800 Subject: [PATCH 2/2] update: readme --- README.md | 81 +++++++++++++++++++++++++++++++++++++++++++---- docs/README-CN.md | 24 ++++++++++++-- 2 files changed, 96 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7d046d9..889c0cb 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,77 @@ # GuGoTik -GuGoTik Repo, more information will be provided after the end of the campus practice. +GuGoTik is sixth practice project of ByteDance campus, themed of a micro TikTok backend. + +If you want to learn more information, please wait util the competition finished. GuGoTik will provide the whole develop document, please give us a star~ + English | [简体中文](docs/README-CN.md) -# File Structure -- src: the code source of the project. -- build: provide build description file. -- docs: provide project build information. -- test: code verify test. +# Contributor +Project Developer: This is a group of Contributors from all over the world, from WHU, HNU, NJUPT. +- [EpicMo](https://github.com/liaosunny123) +- [Maples](https://github.com/Maple-pro) +- [Attacks](https://github.com/Attack825) +- [amazing-compass](https://github.com/amazing-compass) +- [XFFFCCCC](https://github.com/XFFFCCCC) + +特别感谢: +- [Eric](https://github.com/ExerciseBook) +- [Huang Yongliang](https://github.com/956237586) +- [nicognaW](https://github.com/nicognaW) + +以及有事而无法参与项目的小伙伴: +- [Chuanwise](https://github.com/Chuanwise) + +# 项目结构 +- docker: Built as basic image for project's dockerfile or kubernetes's basic infrastructure. +- scripts: Build scripts +- src: The source of the project + - constant: The project constant + - extra: The service being relied upon + - idl: idl + - models: Data model + - rpc: Rpc code + - services: Micro services instance + - storage: About storage + - utils: Utils code + - web: Gateway code +- test: Test of the project +- Others:Docker Compose file and demo env + +# Extern service +- Redis (Cluster) +- PostgreSQL +- Consul +- OpenTelemetry Collector +- FFMpeg +- Go + +Recommend: +- Jaeger +- Victoria Metrics +- Grafana + +Profile Analysis: +- Pyroscope + +# Build process +RyzeBot of 梦想珈 will build image and push to kubernetes +The PR to Dev branch can be merged into the Master branch after the Action based UnitTest + Code Analysis + Lint + BuildCheck. +The Master branch will automatically trigger the CD, build the image and push it, and RyzeBot will complete the push to K8S for automatic deployment. + +# Config +GuGoTik can automatically capture environement variables or provide them manually as .env files in the order of coverage: +.Env > environement variable > DefaultEnv > EmptyEnv (that is, null value is provided by default, and runtime special judgment is provided by GuGoTik) + +# Build +## Standalone +Run the build-all script in the scripts folder, and then run the run-all script. Please select the script supported by your platform. +## Docker +```bash +docker pull epicmo/gugotik:latest +``` +After entering the container through the interactive end point, run the programs under the GateWay folder and the Services folder by yourself +## Docker-Compose +Run in the project root directory: +Note: The relevant account password settings are viewed in the .env.docker.compose file +```bash +docker compose up -d +``` \ No newline at end of file diff --git a/docs/README-CN.md b/docs/README-CN.md index 1e3e0fd..a74008b 100644 --- a/docs/README-CN.md +++ b/docs/README-CN.md @@ -1,5 +1,7 @@ # GuGoTik -GuGoTik是 第六届字节跳动青训营后端进阶 实战项目,题目为编写一个小型的抖音后端。 +GuGoTik是 第六届字节跳动青训营后端进阶 实战项目,题目为编写一个小型的抖音后端。 + +如果你想了解更多信息,请等待 青训营结束后 ,GuGoTik 会提供完整的项目开发文档,请给本项目一个 Star ~ # 贡献者 项目开发者:这是一群来自五湖四海的 Contributors,来自于 WHU,HNU,NJUPT。 - [EpicMo](https://github.com/liaosunny123) @@ -16,6 +18,22 @@ GuGoTik是 第六届字节跳动青训营后端进阶 实战项目,题目为 以及有事而无法参与项目的小伙伴: - [Chuanwise](https://github.com/Chuanwise) +# 项目结构 +- docker: 基础镜像,为项目的Dockerfile提供基础镜像,或者是为 K8S 技术设施提供基础镜像 +- scripts: 构建脚本 +- src: 项目源代码 + - constant: 项目常量 + - extra: 外部服务依赖 + - idl: idl文件 + - models: 数据模型 + - rpc: Rpc 代码 + - services: 微服务实例 + - storage: 存储相关 + - utils: 辅助代码 + - web: 网关代码 +- test: 项目测试 +- 其他单文件:Docker Compose 文件和使用的demo环境变量 + # 外部服务依赖 - Redis (Cluster) - PostgreSQL @@ -34,8 +52,8 @@ Profile 性能分析: # 自部署流程 由 梦想珈 RyzeBot 提供自动推送至K8S集群构建流程。 -PR 至 Dev 分支,经过基于 Action 的 UnitTest + Code Analysis + Lint + BuildCheck 后,可合并至 Master 分支。 -Master 分支会自动触发 CD,构建镜像并推送,由 RyzeBot 完成向 K8S 的推送,自动部署。 +PR 至 Dev 分支,经过基于 Action 的 UnitTest + Code Analysis + Lint + BuildCheck 后,可合并至 endymx 分支。 +endymx 分支会自动触发 CD,构建镜像并推送,由 RyzeBot 完成向 K8S 的推送,自动部署。 # 配置 GuGoTik可以自动捕获环境变量,也可以以 .env 文件的方式手动提供,覆盖顺序为: