{"id":18266806,"url":"https://github.com/chenquan/zero-flow","last_synced_at":"2025-04-04T22:30:30.751Z","repository":{"id":84732858,"uuid":"606349563","full_name":"chenquan/zero-flow","owner":"chenquan","description":"Implement flow staining in go-zero.","archived":false,"fork":false,"pushed_at":"2025-03-17T12:36:51.000Z","size":391,"stargazers_count":7,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T20:14:01.727Z","etag":null,"topics":["go","go-zero","golang","gozero","grpc","microservice"],"latest_commit_sha":null,"homepage":"","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/chenquan.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-25T08:04:14.000Z","updated_at":"2024-11-28T00:17:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"55e9648c-9f30-477d-9867-a167b4deb6f2","html_url":"https://github.com/chenquan/zero-flow","commit_stats":{"total_commits":65,"total_committers":2,"mean_commits":32.5,"dds":0.4769230769230769,"last_synced_commit":"346122e8a5bb9a741ef5d14b969147f1ed6dff9a"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenquan%2Fzero-flow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenquan%2Fzero-flow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenquan%2Fzero-flow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenquan%2Fzero-flow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenquan","download_url":"https://codeload.github.com/chenquan/zero-flow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247260215,"owners_count":20909957,"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":["go","go-zero","golang","gozero","grpc","microservice"],"created_at":"2024-11-05T11:24:56.356Z","updated_at":"2025-04-04T22:30:30.306Z","avatar_url":"https://github.com/chenquan.png","language":"Go","funding_links":["https://www.buymeacoffee.com/chenquan","https://img.buymeacoffee.com/button-api/?text=Buy"],"categories":[],"sub_categories":[],"readme":"# zero-flow\n\n[![Go](https://github.com/chenquan/zero-flow/actions/workflows/go.yml/badge.svg)](https://github.com/chenquan/zero-flow/actions/workflows/go.yml)\n[![CodeQL](https://github.com/chenquan/zero-flow/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/chenquan/zero-flow/actions/workflows/codeql-analysis.yml)\n[![codecov](https://codecov.io/gh/chenquan/zero-flow/branch/master/graph/badge.svg)](https://codecov.io/gh/chenquan/zero-flow)\n\n[![Release](https://img.shields.io/github/v/release/chenquan/zero-flow.svg?style=flat-square)](https://github.com/chenquan/zero-flow)\n[![Download](https://goproxy.cn/stats/github.com/chenquan/zero-flow/badges/download-count.svg)](https://github.com/chenquan/zero-flow)\n[![GitHub](https://img.shields.io/github/license/chenquan/zero-flow)](LICENSE)\n\n\u003e Implement flow staining in go-zero.\n\n![zero-flow.jpeg](./images/zero-flow.png)\n\n## install\n\n```shell\ngo get github.com/chenquan/zero-flow\n```\n\n### rest\n\n*user.yaml*\n\n```yaml\nName: user\nHost: 0.0.0.0\nPort: 8888\nHeaderTag: X-Zero-Flow-Tag\n\nUserRpc:\n  Etcd:\n    Hosts:\n      - 127.0.0.1:2379\n    Key: user.rpc\nLog:\n  Level: debug\n```\n\n*config.go*\n\n```go \npackage config\n\nimport (\n\t\"github.com/chenquan/zero-flow/rest\"\n\t\"github.com/chenquan/zero-flow/zrpc\"\n)\n\ntype Config struct {\n\trest.RestConf\n\tUserRpc zrpc.RpcClientConf\n}\n\n```\n\n```go\npackage main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\n\t\"github.com/chenquan/zero-flow/rest\"\n\t\"github.com/zeromicro/go-zero/core/logx\"\n\n\t\"github.com/zeromicro/go-zero/core/conf\"\n)\n\nvar configFile = flag.String(\"f\", \"etc/user.yaml\", \"the config file\")\n\nfunc main() {\n\tflag.Parse()\n\n\tvar c config.Config\n\tconf.MustLoad(*configFile, \u0026c)\n\tserver := rest.MustNewServer(c.RestConf)\n\tdefer server.Stop()\n\n\tctx := svc.NewServiceContext(c)\n\thandler.RegisterHandlers(server, ctx)\n\tlogx.DisableStat()\n\tfmt.Printf(\"Starting server at %s:%d...\\n\", c.Host, c.Port)\n\tserver.Start()\n}\n\n```\n\n### zrpc server\n\n*user.yaml*\n\n```yaml\nName: user.rpc\nListenOn: 0.0.0.0:8080\nEtcd:\n  Hosts:\n    - 127.0.0.1:2379\n  Key: user.rpc\nTag: red # 定义流量标签，相同流量标签的不同服务在一个调用链路中将构成一个泳道。\nLog:\n  Level: debug\n```\n\n*config.go*\n\n```go\npackage config\n\nimport (\n\t\"github.com/chenquan/zero-flow/zrpc\"\n)\n\ntype Config struct {\n\tzrpc.RpcServerConf\n}\n```\n\n```go\npackage main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\n\t\"github.com/zeromicro/go-zero/core/logx\"\n\n\t\"github.com/chenquan/zero-flow/zrpc\"\n\t\"github.com/zeromicro/go-zero/core/conf\"\n\t\"github.com/zeromicro/go-zero/core/service\"\n\t\"google.golang.org/grpc\"\n\t\"google.golang.org/grpc/reflection\"\n)\n\nvar configFile = flag.String(\"f\", \"etc/user.yaml\", \"the config file\")\n\nfunc main() {\n\tflag.Parse()\n\n\tvar c config.Config\n\tconf.MustLoad(*configFile, \u0026c)\n\tctx := svc.NewServiceContext(c)\n\n\ts := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {\n\t\tuser.RegisterUserServer(grpcServer, server.NewUserServer(ctx))\n\n\t\tif c.Mode == service.DevMode || c.Mode == service.TestMode {\n\t\t\treflection.Register(grpcServer)\n\t\t}\n\t})\n\tlogx.DisableStat()\n\tdefer s.Stop()\n\tfmt.Printf(\"Starting rpc server at %s...\\n\", c.ListenOn)\n\ts.Start()\n}\n\n```\n\n\u003ca href=\"https://www.buymeacoffee.com/chenquan\"\u003e\u003cimg src=\"https://img.buymeacoffee.com/button-api/?text=Buy me a coffee\u0026emoji=\u0026slug=chenquan\u0026button_colour=FFDD00\u0026font_colour=000000\u0026font_family=Poppins\u0026outline_colour=000000\u0026coffee_colour=ffffff\" /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenquan%2Fzero-flow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenquan%2Fzero-flow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenquan%2Fzero-flow/lists"}