{"id":43057507,"url":"https://github.com/vito-go/rpcplus","last_synced_at":"2026-01-31T11:33:04.877Z","repository":{"id":239066596,"uuid":"798395689","full_name":"vito-go/rpcplus","owner":"vito-go","description":"rpcplus is a enchanced library that builds upon the Go language's standard rpc package, offering a suite of enhancements for an improved RPC experience.","archived":false,"fork":false,"pushed_at":"2024-05-12T11:01:02.000Z","size":78,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T12:05:10.340Z","etag":null,"topics":["go-rpc","golang-rpc","rpc","rpc-api","rpc-client","rpc-framework","rpc-library","rpc-server"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vito-go.png","metadata":{"files":{"readme":"README-zh-hans.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":"2024-05-09T17:32:55.000Z","updated_at":"2024-05-26T21:47:52.000Z","dependencies_parsed_at":"2024-06-19T11:14:26.139Z","dependency_job_id":"5ea79e8e-5914-4b69-a86b-6c79bd4af4e6","html_url":"https://github.com/vito-go/rpcplus","commit_stats":null,"previous_names":["vito-go/gorpc","vito-go/rpcplus"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/vito-go/rpcplus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vito-go%2Frpcplus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vito-go%2Frpcplus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vito-go%2Frpcplus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vito-go%2Frpcplus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vito-go","download_url":"https://codeload.github.com/vito-go/rpcplus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vito-go%2Frpcplus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28940475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T10:18:23.202Z","status":"ssl_error","status_checked_at":"2026-01-31T10:18:22.693Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-rpc","golang-rpc","rpc","rpc-api","rpc-client","rpc-framework","rpc-library","rpc-server"],"created_at":"2026-01-31T11:33:03.457Z","updated_at":"2026-01-31T11:33:04.871Z","avatar_url":"https://github.com/vito-go.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## [English](README.md) | [中文版](README-zh-hans.md)\n\n# rpcplus\nrpcplus是一个基于Go语言标准rpc包进行优化的库，提供了一系列增强功能，用于提升RPC体验。\n\n## 主要特点\n- 支持RPC服务端直接注册函数，简化服务提供过程。\n- 允许注册匿名函数，为灵活编程提供便利。\n- 自动注册接收者的所有**适用**的方法（通常是结构体）\n  - **适用**的定义请查阅[函数注册](#函数注册)\n- 函数支持接收多个参数，提高调用的灵活性。\n- 支持传递context.Context参数，用于更复杂的上下文管理, 如超时、取消等。\n- 支持 Go 风格的返回值模式，允许函数返回 `(T, error)`或者`error`。\n- 保留jsonrpc支持，提升跨语言通讯的便捷性\n\n以上关键特性使得 rpcplus 成为一个功能全面而强大的 RPC 框架。\n\n\n## 使用\n- ### 服务端\n    ```go\n        package  main\n        import (\n            \"context\"\n            \"github.com/vito-go/rpcplus\"\n            \"log\"\n            \"net\"\n        )\n        // look at the example/example.go Stu and Add \n        func main()  {\n            log.SetFlags(log.Lshortfile | log.LstdFlags)\n            s := rpcplus.NewServer()\n            err := s.RegisterRecv(\u0026Stu{})\n            if err != nil {\n                panic(err)\n            }\n            err = s.RegisterFunc(\"Add\", Add)\n            if err != nil {\n                panic(err)\n            }\n            err = s.RegisterFunc(\"Anonymous\", func(ctx context.Context, x int, y int) (int64, error) {\n                return int64(x * y), nil\n            })\n            if err != nil {\n                panic(err)\n            }\n            lis, err := net.Listen(\"tcp\", \":8081\")\n            if err != nil {\n                panic(err)\n            }\n            log.Println(\"rpcplus: Starting server on port 8081\")\n            s.Serve(lis)\n        }\n    ```\n- ### 客户端\n    ```go\n        package main\n        import (\n            \"context\"\n            \"github.com/vito-go/rpcplus\"\n            \"net\"\n        )\n        // look at the example/example.go UserInfo\n        func main()  {\n            dialer, err := net.Dial(\"tcp\", \"127.0.0.1:8081\")\n            if err != nil {\n                panic(err)\n            }\n            cli := rpcplus.NewClient(dialer)\n            ctx := context.Background()\n            var result UserInfo\n            err = cli.Call(ctx, \"Stu.GetUserInfoByUserId\", \u0026result, 181)\n            if err != nil {\n                panic(err)\n            }\n        }\n    \n    \n    ```\n\n## 函数注册\n- 要求函数满足以下条件：\n  - 一个参数或多个参数，首个为 context.Context 类型\n  - 返回类型：单个 error 或两个值，第二个为 error 类型。\n\n- ### 示例\n  ```go\n    func add(ctx context.Context, x int,y int) (int, error)\n    \n    func GetAgeByName(ctx context.Context, name string) (int, error)\n    \n    func GetAgeByClassIdAndName(ctx context.Context,classId int,name string) (int, error)\n    \n    type UserInfo struct{\n        Name string\n        Age int\n        ClassId int\n    }\n    \n    func GetUserInfoByUserId(ctx context.Context,userId int) (*UserInfo, error)\n    \n    func UpdateUserInfo(ctx context.Context, u *UserInfo) (int64, error)\n  \n  ```\n\n### 服务函数列表 (测试用例)\n- ### 来自 debugHTTP\n  \u003ctable border=\"1\" cellpadding=\"5\"\u003e\n  \u003ctbody\u003e\u003ctr\u003e\u003cth align=\"center\"\u003eService\u003c/th\u003e\u003cth align=\"center\"\u003eMethodType\u003c/th\u003e\u003cth align=\"center\"\u003eCalls\u003c/th\u003e\n          \u003c/tr\u003e\u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003eArith.Add\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003eArith.Div\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003eArith.Error\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003eArith.Mul\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003eArith.Scan\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, string) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003eArith.SleepMilli\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003eArith.String\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*string, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003eEmbed.Exported\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enet.rpcplus.Arith.Add\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enet.rpcplus.Arith.Div\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enet.rpcplus.Arith.Error\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enet.rpcplus.Arith.Mul\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enet.rpcplus.Arith.Scan\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, string) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enet.rpcplus.Arith.SleepMilli\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enet.rpcplus.Arith.String\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*string, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enewServer.Arith.Add\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enewServer.Arith.Div\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enewServer.Arith.Error\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enewServer.Arith.Mul\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enewServer.Arith.Scan\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, string) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enewServer.Arith.SleepMilli\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, rpcplus.Args) (*rpcplus.Reply, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n          \u003ctr\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003enewServer.Arith.String\u003c/td\u003e\n          \u003ctd align=\"left\" font=\"fixed\"\u003efunc(context.Context, *rpcplus.Args) (*string, error)\u003c/td\u003e\n          \u003ctd align=\"center\"\u003e0\u003c/td\u003e\u003c/tr\u003e\n  \u003c/tbody\u003e\u003c/table\u003e\n\n## 测试用例\n\n本项目已经通过了全部的测试用例，确保了代码的质量和可靠性。我们鼓励贡献者在提交代码前运行测试，以维护项目的稳定性。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvito-go%2Frpcplus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvito-go%2Frpcplus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvito-go%2Frpcplus/lists"}