{"id":26129188,"url":"https://github.com/elarity/ti-rpc","last_synced_at":"2025-04-13T18:35:53.172Z","repository":{"id":152858151,"uuid":"71433212","full_name":"elarity/ti-rpc","owner":"elarity","description":"基于swoole封装的一个简易的JSON协议的RPC框架，思路是借鉴的，代码是自己写的。小修小改的，目前服务于前公司（注意是前公司）生产环境，每日支撑大约8000万次调用。","archived":false,"fork":false,"pushed_at":"2019-07-23T09:54:54.000Z","size":1336,"stargazers_count":144,"open_issues_count":0,"forks_count":24,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-27T09:13:22.385Z","etag":null,"topics":["json","rpc","swoole","tcp"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/elarity.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":"2016-10-20T06:43:38.000Z","updated_at":"2025-02-27T16:41:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"db0f6ccb-2c49-4e5e-8912-d5cea3d06615","html_url":"https://github.com/elarity/ti-rpc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elarity%2Fti-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elarity%2Fti-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elarity%2Fti-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elarity%2Fti-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elarity","download_url":"https://codeload.github.com/elarity/ti-rpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248761442,"owners_count":21157558,"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":["json","rpc","swoole","tcp"],"created_at":"2025-03-10T19:39:56.259Z","updated_at":"2025-04-13T18:35:53.157Z","avatar_url":"https://github.com/elarity.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ti RPC\n\n## swoole版本说明\n这个东西做出来的时候时间比较早，当时swoole 2.0也才刚发版没多久。所以，这个玩意在swoole 1.x系列和swoole 2.x系列里是没什么问题的。但是swoole 4可能发生的一些变动可能会导致这个玩意报一些错。我建议是：swoole 4情况下，不优先考虑这个；如果一定要考虑，自己修一下吧。因为swoole后面是重协程的，而咱这个玩意主要思路还是多进程方式。至于会不会改进做一个协程版本的：会做。但是没有经历至少几十万用户验证前，我应该不会轻易扔出来的。现有的这个版本虽然在协程时代显得LOW，但是贵在经历过百万级的用户体量考验。\n\n## 简要概述：\n封装的比较简单，代码风格略粗暴，没有过多的组件以及厚重的包装，我不太喜欢过于复杂的东西。整体思路是借鉴蓝天的，代码则自己实现（你也可以认为是抄袭），自己做了些许改动。由于第一个版本我实现的比较烂，所以没有放出来，这个版本代码略干净能看一些，又在我们公司生产环境经过长期的验证，每日支撑将近8000万次的调用，所以我就放出来了。\n\n我不会刻意去推广这个，也会长期改进维护，只希望能帮到一些人。\n\n\n## TODO LIST：\n1.加入更好的异常机制代替丑陋的if else\n\n2.加入包头定长拆包协议（已实现）\n\n## VIM配置\n\nset shiftwidth=2\n\nset softtabstop=2\n\nset tabstop=2\n\nset rnu\n\nset fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1\n\nset enc=utf8\n\nset fencs=utf8,gbk,gb2312,gb18030\n\n\n## 功能简介：\n1.同时提供tcp和http两种方式。\n\n2.提供四种不同调用方式：\n \n SW : 单个请求,等待结果\n \n SN : 单个请求,不等待结果\n \n MW : 多个请求,等待结果\n  \n MN : 多个请求,不等待结果  \n\n3.客户端可以通过长链接连接RPC服务，避免TCP握挥手带来的性能损耗\n\n4.TCP提供根据数据长度拆包和包头定长两种拆包方式，默认启用包头定长\n\n5.其余特性参考 http://wiki.swoole.com\n\n\n\n## 部署安装\n1. git clone https://github.com/elarity/ti-rpc.git\n2. 到ti-rpc根目录下执行php index.php查看使用方式\n\n已经加入对composer的支持，根目录下有个composer.json，请不要随意修改其中内容如果你明白你在做什么操作。如果你需要从github找到一个php库并使用，比如这个[curl类](https://github.com/php-curl-class/php-curl-class)，那么你需要在ti rpc的根目录下执行如下命令：\n\n```php\ncomposer require php-curl-class/php-curl-class\n```\n这个时候，ti rpc将会采用composer自动加载器而不是自定义的自动加载，从而可以方便粗暴快捷简单地使用任何一个php composer库\n\n\n\n\n## 使用方式\n##### php index.php [command] [option]\n- start，以非daemon形式开始服务，也就是debug模式\n- start -d，以daemon模式开启服务，一般用于正式部署\n- stop，停止服务\n- reload，热加载业务代码\n- status，查看服务状态\n\n![](http://static.ti-node.com/github_tirpc_1.png)\n\n## 内容添加\n1. 添加curl和RNCryptor加解密库\n\n## 联系方式：\nwechat：sbyuanmaomao\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felarity%2Fti-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felarity%2Fti-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felarity%2Fti-rpc/lists"}