{"id":13416825,"url":"https://github.com/aceld/zinx","last_synced_at":"2025-05-15T00:05:38.844Z","repository":{"id":37405775,"uuid":"167186080","full_name":"aceld/zinx","owner":"aceld","description":"A lightweight concurrent server framework based on Golang.","archived":false,"fork":false,"pushed_at":"2025-05-06T06:39:56.000Z","size":38086,"stargazers_count":7339,"open_issues_count":80,"forks_count":1227,"subscribers_count":162,"default_branch":"master","last_synced_at":"2025-05-06T07:52:26.074Z","etag":null,"topics":["game-server","go","golang","tcp-server","zinx"],"latest_commit_sha":null,"homepage":"https://github.com/aceld/zinx/wiki","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aceld.png","metadata":{"files":{"readme":"README-CN.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":["aceld"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null}},"created_at":"2019-01-23T13:15:31.000Z","updated_at":"2025-05-06T07:50:43.000Z","dependencies_parsed_at":"2024-01-03T06:40:32.138Z","dependency_job_id":"f0e9c5f0-5d7f-4a2c-8021-14b95b343857","html_url":"https://github.com/aceld/zinx","commit_stats":{"total_commits":542,"total_committers":69,"mean_commits":7.855072463768116,"dds":0.525830258302583,"last_synced_commit":"e442c383d3af883301677dec2305718ae87f4c4d"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceld%2Fzinx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceld%2Fzinx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceld%2Fzinx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceld%2Fzinx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aceld","download_url":"https://codeload.github.com/aceld/zinx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252873974,"owners_count":21817710,"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":["game-server","go","golang","tcp-server","zinx"],"created_at":"2024-07-30T22:00:22.812Z","updated_at":"2025-05-07T11:52:55.008Z","avatar_url":"https://github.com/aceld.png","language":"Go","readme":"# \u003cimg width=\"80px\" src=\"https://s2.ax1x.com/2019/10/09/u4yHo9.png\" /\u003e \n\n[English](README.md) | 简体中文\n\n[![License](https://img.shields.io/badge/License-MIT-black.svg)](LICENSE)\n[![Discord](https://img.shields.io/badge/zinx-Discord在线社区-blue.svg)](https://discord.gg/xQ8Xxfyfcz)\n[![Gitter](https://img.shields.io/badge/zinx-Gitter在线交流-green.svg)](https://gitter.im/zinx_go/community)\n[![zinx tutorial](https://img.shields.io/badge/Zinx教程-YuQue-red.svg)](https://www.yuque.com/aceld/npyr8s/bgftov)\n[![Original Book of Zinx](https://img.shields.io/badge/原创书籍-YuQue-black.svg)](https://www.yuque.com/aceld)\n\nZinx 是一个基于Golang的轻量级并发服务器框架\n\n## 开发者文档\n\n[ \u003c Zinx Wiki : English \u003e ](https://github.com/aceld/zinx/wiki)\n\n[ \u003c Zinx 文档 : 简体中文\u003e ](https://www.yuque.com/aceld/tsgooa/sbvzgczh3hqz8q3l)\n\n\u003e **说明**:目前zinx已经在很多企业进行开发使用，具体使用领域包括:后端模块的消息中转、长连接游戏服务器、Web框架中的消息处理插件等。zinx的定位是代码简洁，让更多的开发者迅速的了解框架的内脏细节并且可以快速基于zinx DIY(二次开发)一款适合自己企业场景的模块。\n\n---\n## zinx源码地址\n| platform | Entry | \n| ---- | ---- | \n|Github| https://github.com/aceld/zinx |\n|Gitcode|https://gitcode.com/aceld/zinx|\n|Gitee|https://gitee.com/Aceld/zinx|\n\n### 官网\nhttp://zinx.me\n\n---\n\n## 在线开发教程\n\n### 文字教程\n\n| platform | Entry | \n| ---- | ---- | \n| \u003cimg src=\"https://user-images.githubusercontent.com/7778936/236784004-b6d99e26-b1ab-4bc3-988e-7a46108b85fe.png\" width = \"100\" height = \"100\" alt=\"\" align=center /\u003e| [Zinx Framework tutorial-Lightweight server based on Golang](https://dev.to/aceld/1building-basic-services-with-zinx-framework-296e)| \n|\u003cimg src=\"https://user-images.githubusercontent.com/7778936/236784168-6528a9b8-d37b-4b02-a37c-b9988d7508d8.jpeg\" width = \"100\" height = \"100\" alt=\"\" align=center /\u003e|[《Golang轻量级并发服务器框架zinx》](https://www.yuque.com/aceld)|\n\n\n### 视频教程\n\n| platform | online video | \n| ---- | ---- | \n| \u003cimg src=\"https://s1.ax1x.com/2022/09/22/xFePUK.png\" width = \"100\" height = \"100\" alt=\"\" align=center /\u003e| [![zinx-BiliBili](https://s2.ax1x.com/2019/10/13/uv340S.jpg)](https://www.bilibili.com/video/av71067087)| \n| \u003cimg src=\"https://s1.ax1x.com/2022/09/22/xFesxJ.png\" width = \"100\" height = \"80\" alt=\"\" align=center /\u003e  | [![zinx-BiliBili](https://s2.ax1x.com/2019/10/13/uv340S.jpg)](https://www.douyin.com/video/6983301202939333891) |\n| \u003cimg src=\"https://s1.ax1x.com/2022/09/23/xkQcng.png\" width = \"100\" height = \"100\" alt=\"\" align=center /\u003e| [![zinx-youtube](https://s2.ax1x.com/2019/10/14/KSurCR.jpg)](https://www.youtube.com/watch?v=U95iF-HMWsU\u0026list=PL_GrAPKmuajzeNI8HBTi-k5NQO1g0rM-A)| \n\n    \n## 一、写在前面\n\n我们为什么要做Zinx，Golang目前在服务器的应用框架很多，但是应用在游戏领域或者其他长连接的领域的轻量级企业框架甚少。\n\n设计Zinx的目的是我们可以通过Zinx框架来了解基于Golang编写一个TCP服务器的整体轮廓，让更多的Golang爱好者能深入浅出的去学习和认识这个领域。\n\nZinx框架的项目制作采用编码和学习教程同步进行，将开发的全部递进和迭代思维带入教程中，而不是一下子给大家一个非常完整的框架去学习，让很多人一头雾水，不知道该如何学起。\n\n教程会一个版本一个版本迭代，每个版本的添加功能都是微小的，让一个服务框架小白，循序渐进的曲线方式了解服务器框架的领域。\n\n当然，最后希望Zinx会有更多的人加入，给我们提出宝贵的意见，让Zinx成为真正的解决企业的服务器框架！在此感谢您的关注！\n\n\n\n\n## 二、初探Zinx架构\n![Zinx框架](https://user-images.githubusercontent.com/7778936/220058446-0ad45112-2225-4b71-b0d8-69a7f3cee5ca.jpg)\n\n![流程图](https://github.com/wenyoufu/testaaaaaa/blob/abc8a50078a86aed37e8af6082d1d867bc165c32/%E6%9C%AA%E5%91%BD%E5%90%8D%E6%B5%81%E7%A8%8B%E5%9B%BE%20(1).jpg?raw=true)\n![zinx-start](https://user-images.githubusercontent.com/7778936/126594039-98dddd10-ec6a-4881-9e06-a09ec34f1af7.gif)\n\n\n\n## 三、Zinx开发接口文档\n\n\n### （1）快速开始\n\n[\u003cZinx的Tcp调试工具\u003e](https://github.com/xxl6097/tcptest)\n\n**版本**\nGolang 1.17+\n\nDownLoad zinx Source\n\n```bash\n$go get github.com/aceld/zinx\n```\n\n\u003e note: Golang Version 1.17+\n\n#### Zinx-Server\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/aceld/zinx/ziface\"\n\t\"github.com/aceld/zinx/znet\"\n)\n\n// PingRouter MsgId=1的路由\ntype PingRouter struct {\n\tznet.BaseRouter\n}\n\n//Ping Handle MsgId=1的路由处理方法\nfunc (r *PingRouter) Handle(request ziface.IRequest) {\n\t//读取客户端的数据\n\tfmt.Println(\"recv from client : msgId=\", request.GetMsgID(), \", data=\", string(request.GetData()))\n}\n\nfunc main() {\n\t//1 创建一个server服务\n\ts := znet.NewServer()\n\n\t//2 配置路由\n\ts.AddRouter(1, \u0026PingRouter{})\n\n\t//3 启动服务\n\ts.Serve()\n}\n\n```\n\nRun Server\n\n```bash\n$ go run server.go\n```\n\n```bash\n                                        \n              ██                        \n              ▀▀                        \n ████████   ████     ██▄████▄  ▀██  ██▀ \n     ▄█▀      ██     ██▀   ██    ████   \n   ▄█▀        ██     ██    ██    ▄██▄   \n ▄██▄▄▄▄▄  ▄▄▄██▄▄▄  ██    ██   ▄█▀▀█▄  \n ▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀  ▀▀    ▀▀  ▀▀▀  ▀▀▀ \n                                        \n┌──────────────────────────────────────────────────────┐\n│ [Github] https://github.com/aceld                    │\n│ [tutorial] https://www.yuque.com/aceld/npyr8s/bgftov │\n└──────────────────────────────────────────────────────┘\n[Zinx] Version: V1.0, MaxConn: 12000, MaxPacketSize: 4096\n===== Zinx Global Config =====\nTCPServer: \u003cnil\u003e\nHost: 0.0.0.0\nTCPPort: 8999\nName: ZinxServerApp\nVersion: V1.0\nMaxPacketSize: 4096\nMaxConn: 12000\nWorkerPoolSize: 10\nMaxWorkerTaskLen: 1024\nMaxMsgChanLen: 1024\nConfFilePath: /Users/Aceld/go/src/zinx-usage/quick_start/conf/zinx.json\nLogDir: /Users/Aceld/go/src/zinx-usage/quick_start/log\nLogFile: \nLogIsolationLevel: 0\nHeartbeatMax: 10\n==============================\n2023/03/09 18:39:49 [INFO]msghandler.go:61: Add api msgID = 1\n2023/03/09 18:39:49 [INFO]server.go:112: [START] Server name: ZinxServerApp,listenner at IP: 0.0.0.0, Port 8999 is starting\n2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 0 is started.\n2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 1 is started.\n2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 3 is started.\n2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 2 is started.\n2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 4 is started.\n2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 6 is started.\n2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 7 is started.\n2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 8 is started.\n2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 9 is started.\n2023/03/09 18:39:49 [INFO]msghandler.go:66: Worker ID = 5 is started.\n2023/03/09 18:39:49 [INFO]server.go:134: [START] start Zinx server  ZinxServerApp succ, now listenning...\n\n```\n\n\n\n#### Zinx-Client\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/aceld/zinx/ziface\"\n\t\"github.com/aceld/zinx/znet\"\n\t\"time\"\n)\n\n//客户端自定义业务\nfunc pingLoop(conn ziface.IConnection) {\n\tfor {\n\t\terr := conn.SendMsg(1, []byte(\"Ping...Ping...Ping...[FromClient]\"))\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tbreak\n\t\t}\n\n\t\ttime.Sleep(1 * time.Second)\n\t}\n}\n\n//创建连接的时候执行\nfunc onClientStart(conn ziface.IConnection) {\n\tfmt.Println(\"onClientStart is Called ... \")\n\tgo pingLoop(conn)\n}\n\nfunc main() {\n\t//创建Client客户端\n\tclient := znet.NewClient(\"127.0.0.1\", 8999)\n\n\t//设置连接建立成功后的钩子函数\n\tclient.SetOnConnStart(onClientStart)\n\n\t//启动客户端\n\tclient.Start()\n\n\t//防止进程退出，等待中断信号\n\tselect {}\n}\n\n```\n\nRun Client\n\n```bash\n$ go run client.go \n2023/03/09 19:04:54 [INFO]client.go:73: [START] Zinx Client LocalAddr: 127.0.0.1:55294, RemoteAddr: 127.0.0.1:8999\n2023/03/09 19:04:54 [INFO]connection.go:354: ZINX CallOnConnStart....\n```\n\nTerminal of Zinx Print:\n```bash\nrecv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]\nrecv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]\nrecv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]\nrecv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]\nrecv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]\nrecv from client : msgId= 1 , data= Ping...Ping...Ping...[FromClient]\n...\n```\n\n\n### （2）Zinx配置文件\n```json\n{\n  \"Name\":\"zinx v-0.10 demoApp\",\n  \"Host\":\"0.0.0.0\",\n  \"TCPPort\":9090,\n  \"MaxConn\":3,\n  \"WorkerPoolSize\":10,\n  \"LogDir\": \"./mylog\",\n  \"LogFile\":\"app.log\",\n  \"LogSaveDays\":15,\n  \"LogCons\": true,\n  \"LogIsolationLevel\":0\n}\n```\n\n`Name`:服务器应用名称\n\n`Host`:服务器IP\n\n`TcpPort`:服务器监听端口\n\n`MaxConn`:允许的客户端连接最大数量\n\n`WorkerPoolSize`:工作任务池最大工作Goroutine数量\n\n`LogDir`: 日志文件夹\n\n`LogFile`: 日志文件名称(如果不提供，则日志信息打印到Stderr)\n\n`LogIsolationLevel`: 日志隔离级别 0：全开, 1：关debug, 2：关debug/info, 3：关debug/info/warn \n\n---\n\n#### 开发者\n| **Zinx**                                               | **开发者**  |\n|--------------------------------------------------------| ----  | \n| [zinx](https://github.com/aceld/zinx)                  |刘丹冰([@aceld](https://github.com/aceld)) 张超([@zhngcho](https://github.com/zhngcho)) 高智辉Roger([@adsian](https://github.com/adsian)) 胡贵建([@huguijian](https://github.com/huguijian)) 张继瑀([@kstwoak](https://github.com/kstwoak)) 夏小力([@xxl6097](https://github.com/xxl6097)) 李志成([@clukboy](https://github.com/clukboy)）姚承政([@hcraM41](https://github.com/hcraM41)）李国杰([@LI-GUOJIE](https://github.com/LI-GUOJIE)）余喆宁([@YanHeDoki](https://github.com/YanHeDoki)）|\n| [moke-kit(微服务框架)](https://github.com/GStones/moke-kit) |GStones([@GStones](https://github.com/GStones))|\n| [zinx(C++)](https://github.com/marklion/zinx)          |刘洋([@marklion](https://github.com/marklion))|\n| [zinx(Lua)](https://github.com/huqitt/zinx-lua)        |胡琪([@huqitt](https://github.com/huqitt))|\n| [ginx(Java)](https://github.com/ModuleCode/ginx)       |ModuleCode([@ModuleCode](https://github.com/ModuleCode))|\n\n---\n\n感谢所有为zinx贡献的开发者\n\n\n\u003ca href=\"https://github.com/aceld/zinx/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=aceld/zinx\" /\u003e\n\u003c/a\u003e    \n\n\n---\n### 关于作者：\n\n作者：`Aceld(刘丹冰)`\n\n`mail`:\n[danbing.at@gmail.com](mailto:danbing.at@gmail.com)\n\n`github`:\n[https://github.com/aceld](https://github.com/aceld)\n\n`原创书籍`:\n[https://www.yuque.com/aceld](https://www.yuque.com/aceld)\n\n\n### 加入Zinx技术社区\n\n| platform | Entry | \n| ---- | ---- | \n| \u003cimg src=\"https://user-images.githubusercontent.com/7778936/236775008-6bd488e3-249a-4d43-8885-7e3889e11e2d.png\" width = \"100\" height = \"100\" alt=\"\" align=center /\u003e| https://discord.gg/xQ8Xxfyfcz| \n| \u003cimg src=\"https://user-images.githubusercontent.com/7778936/236775137-5381f8a6-f534-49c4-8628-e52bf245c3bc.jpeg\" width = \"100\" height = \"100\" alt=\"\" align=center /\u003e  | 加微信: `ace_ld`  或扫二维码，备注`zinx`即可。\u003c/br\u003e\u003cimg src=\"https://user-images.githubusercontent.com/7778936/236781258-2f0371bd-5797-49e8-a74c-680e9f15843d.png\" width = \"150\" height = \"150\" alt=\"\" align=center /\u003e |\n|\u003cimg src=\"https://user-images.githubusercontent.com/7778936/236778547-9cdadfb6-0f62-48ac-851a-b940389038d0.jpeg\" width = \"100\" height = \"100\" alt=\"\" align=center /\u003e|\u003cimg src=\"https://s1.ax1x.com/2020/07/07/UFyUdx.th.jpg\" height = \"150\"  alt=\"\" align=center /\u003e **WeChat Public Account** |\n|\u003cimg src=\"https://user-images.githubusercontent.com/7778936/236779000-70f16c8f-0eec-4b5f-9faa-e1d5229a43e0.png\" width = \"100\" height = \"100\" alt=\"\" align=center /\u003e|\u003cimg src=\"https://s1.ax1x.com/2020/07/07/UF6Y9S.th.png\" width = \"150\" height = \"150\" alt=\"\" align=center /\u003e **QQ Group** |\n","funding_links":["https://github.com/sponsors/aceld"],"categories":["Popular","开源类库","Go","Open source library","语言资源库","Go (531)","Repositories"],"sub_categories":["TCP 框架","TCP Frame","go"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faceld%2Fzinx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faceld%2Fzinx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faceld%2Fzinx/lists"}