{"id":38686458,"url":"https://github.com/gen-iot/rpcx","last_synced_at":"2026-01-17T10:24:35.468Z","repository":{"id":57486271,"uuid":"198447063","full_name":"gen-iot/rpcx","owner":"gen-iot","description":"Easy to use and developer friendly RPC library","archived":false,"fork":false,"pushed_at":"2020-07-02T02:11:01.000Z","size":110,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"v2","last_synced_at":"2025-08-13T22:25:11.926Z","etag":null,"topics":["asynchronous","esay-to-use","middlewares","rpc"],"latest_commit_sha":null,"homepage":"","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/gen-iot.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}},"created_at":"2019-07-23T14:26:43.000Z","updated_at":"2022-11-09T18:04:03.000Z","dependencies_parsed_at":"2022-09-01T21:02:06.380Z","dependency_job_id":null,"html_url":"https://github.com/gen-iot/rpcx","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/gen-iot/rpcx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gen-iot%2Frpcx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gen-iot%2Frpcx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gen-iot%2Frpcx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gen-iot%2Frpcx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gen-iot","download_url":"https://codeload.github.com/gen-iot/rpcx/tar.gz/refs/heads/v2","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gen-iot%2Frpcx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28506438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: 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":["asynchronous","esay-to-use","middlewares","rpc"],"created_at":"2026-01-17T10:24:34.686Z","updated_at":"2026-01-17T10:24:35.455Z","avatar_url":"https://github.com/gen-iot.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rpcx\n\nEasy to use and developer friendly **RPC library**\n\n![go report](https://goreportcard.com/badge/github.com/gen-iot/rpcx)\n![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/gen-iot/rpcx)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://github.com/gen-iot/rpcx/pulls)\n[![Ask Me Anything !](https://img.shields.io/badge/Ask%20me-anything-1abc9c.svg)](https://github.com/gen-iot/rpcx/issues)\n\n## Difference Between Other RPC Libraries\n\n- Once **Callable** established, local and remote are both in **Full duplex** mode.\n- No more **client** or **server** roles, **Callables** can **call/called** each others\n- Lots of **Middlewares** and developer can **Custom** their own middleware!\n- It works without any proto files , just define functions as usual.\n- Based on asynchronous I/O [**(liblpc)**](https://github.com/gen-iot/liblpc) and provides synchronous call semantics\n- **High Performace**: event drivend, msgpack(for serialize),reuse context,goroutine pool...\n\n\n## Usage\n\n\n```bash\n# install rpcx v2\ngo get -u github.com/gen-iot/rpcx/v2@latest\n```\n\n```go\n// import \nimport \"github.com/gen-iot/rpcx/v2\"\n```\n\n## Overview\n\n- **Developer friendly**\n- **Middlewares**: dump,mq_proxy,recover,validate...\n\n## Middlewares\n\n|     Name     |                       Desciption                       |\n| :----------: | :----------------------------------------------------: |\n|     dump     |             dump request/response content              |\n|   mq_proxy   | transfer requst/response\u003cbr\u003e over custom message queue |\n|   recover    |                     recover panic                      |\n|   validate   |             validate request/response data             |\n| req_not_nill |        discard  request which req param is nil         |\n\n## Getting Started\n\n\n### RPC Functions Formal\n\n **Remember :param `ctx`,`err` always required**\n\n1. Both have `in`\u0026`out`\n```go\nfunc Function(ctx rpcx.Context, in InType)(out OutType, err error)\n```\n2. Only `err` \n\n```go\nfunc Function(ctx rpcx.Context)(err error)\n```\n\n3.  `out`  and `err`\n```go\nfunc Function(ctx rpcx.Context) (out OutType,err error)\n```\n\n4.  `in` and `err`\n```go\nfunc Function(ctx rpcx.Context, in InType)(err error)\n```\n\n### Create Core\n\n```go\ncore, err := rpcx.New()\n```\n\n### Close Core\n\n```go\nerr := core.Close()\n```\n\n### Register RPC Function\n\n```go\ncore, err := rpcx.New()\nstd.AssertError(err, \"new rpc\")\ncore.RegFuncWithName(\n    \"hello\", // manual specified func name\n    func(ctx rpcx.Context, msg string) (string, error) {\n        return \"hello from server\", nil\n    })\n```\n\n### Connect To Remote Core\n\n```go\nsockAddr, err := liblpc.ResolveTcpAddr(\"127.0.0.1\")\nstd.AssertError(err,\"resolve addr\")\ncallable := rpcx.NewClientStreamCallable(core, sockAddr, nil)\ncallable.Start()\n```\n\n### Add Exist Conn To Core\n\n```go\n// `fd` must be a valid file descriptor\ncallable := rpcx.NewConnStreamCallable(core,fd, nil)\ncallable.Start()\n```\n\n### Invoke RPC Functions\n\n**Suppose there is a remote function:**\n\n```go\nfunc hello(ctx rpcx.Context)(string,error)\n```\n\n**Now call it**\n\n```go\nout := new(string)\nerr := callable.Call3(time.Second*5, \"hello\", out)\nstd.AssertError(err, \"call 'hello'\")\nfmt.Println(\"result:\",*out)\n```\n\n\n## Callable Calls\n\n**All Call[0-6] support Timeout And Middlewares**\n\n| Function | Header |  In   |  Out  |\n| :------: | :----: | :---: | :---: |\n|   Call   |        |       |       |\n|  Call0   |   ✅    |       |       |\n|  Call1   |        |   ✅   |       |\n|  Call2   |   ✅    |   ✅   |       |\n|  Call3   |        |       |   ✅   |\n|  Call4   |   ✅    |       |   ✅   |\n|  Call5   |        |   ✅   |   ✅   |\n|  Call6   |   ✅    |   ✅   |   ✅   |\n\n## Middleware\n\nmiddlewares works like `AOP concept` as we know in `Java`.\n\n📌**Import middlewares before use**\n```go\nimport \"github.com/gen-iot/rpcx/v2/middleware\"\n```\n### RPC Core\n\n📌**middlewares apply on rpc core will affect whole rpc context**\n\n```go\ncore, err := rpcx.New()\nstd.AssertError(err, \"new rpc core\")\ncore.Use(\n    middleware.Recover(true), // recover \n    middleware.ValidateStruct( // validator\n        middleware.ValidateInOut,\n        std.NewValidator(std.LANG_EN)),\n)\n```\n\n### RPC Functions\n\n```go\ncore, err := rpcx.New()\nstd.AssertError(err, \"new rpc\")\ncore.RegFuncWithName(\"hello\",\n    func(ctx rpcx.Context, msg string) (string, error) {\n        return \"hello from server\", nil\n    },\n    middleware.LoginRequred(),  // require logined\n    middleware.MustAdmin(),       // require admin role\n)\n\n```\n\n### Callable\n\nsimple call\n\n```go\nerr := callable.Call(\"hello\",\n    middleware.Recover(true), // recover \n)\n```\n\nsimple call with headers\n\n```go\nackHeader, err := callable.Call1(\"helloWithHeader\",\u0026RpcMsgHeader{\n                    \"key1\":\"value1\",\n                    \"key2\":\"value2\",\n                },\n    middleware.Recover(true), // recover \n)\nfmt.Println(\"ack header-\u003e\",ackHeader)\n```\n\n## More Example\n\ntry [examples](https://github.com/gen-iot/rpcx/tree/v2/examples)\n\n\n## License\n\nReleased under the [MIT License](https://github.com/gen-iot/rpcx/blob/v2/License)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgen-iot%2Frpcx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgen-iot%2Frpcx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgen-iot%2Frpcx/lists"}