{"id":20031633,"url":"https://github.com/hmgle/cprpc","last_synced_at":"2025-03-02T05:24:30.854Z","repository":{"id":144203779,"uuid":"207301717","full_name":"hmgle/cprpc","owner":"hmgle","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-26T08:00:47.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-12T18:09:17.637Z","etag":null,"topics":["rpc"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hmgle.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":"2019-09-09T12:17:21.000Z","updated_at":"2023-12-24T18:08:35.000Z","dependencies_parsed_at":"2023-06-19T05:53:38.018Z","dependency_job_id":null,"html_url":"https://github.com/hmgle/cprpc","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmgle%2Fcprpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmgle%2Fcprpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmgle%2Fcprpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmgle%2Fcprpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmgle","download_url":"https://codeload.github.com/hmgle/cprpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241462510,"owners_count":19966878,"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":["rpc"],"created_at":"2024-11-13T09:34:07.381Z","updated_at":"2025-03-02T05:24:30.830Z","avatar_url":"https://github.com/hmgle.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cprpc\n\n`cprpc` is a RPC package that copied and modified from the standard package of `net/rpc`, provides an easier way to use:\n\n## Usage\n\nServer:\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net\"\n\n\t\"github.com/hmgle/cprpc\"\n)\n\ntype (\n\tHelloV1API struct {\n\t\tName string\n\t}\n\tHelloV1Ret struct {\n\t\tData string\n\t}\n)\n\nfunc (h *HelloV1API) Serve(ctx *cprpc.Context) {\n\tctx.ReplyOk(\u0026HelloV1Ret{\n\t\tData: \"hello, \" + h.Name,\n\t})\n}\n\nfunc main() {\n\tsrv := cprpc.NewServer()\n\tsrv.RegisterAPI(\"/v1/hello\", \u0026HelloV1API{})\n\n\tlistener, err := net.Listen(\"tcp\", \":1234\")\n\tif err != nil {\n\t\tlog.Fatal(\"ListenTCP error:\", err)\n\t}\n\tsrv.Serve(listener)\n}\n```\n\nClient:\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/hmgle/cprpc\"\n)\n\nfunc main() {\n\tclient, err := cprpc.Dial(\"tcp4\", \"127.0.0.1:1234\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\targs := \u0026HelloV1API{\n\t\tName: \"world\",\n\t}\n\treply := \u0026HelloV1Ret{}\n\terr = client.Call(\"/v1/hello\", args, \u0026reply)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tlog.Printf(\"reply: %+v\\n\", reply)\n}\n```\n\n## Performance\n\nBelow are benchmark results comparing cprpc performance to net/rpc:\n\n```\n$ go test -bench=. -benchmem -run=none\ngoos: linux\ngoarch: amd64\npkg: github.com/hmgle/cprpc\ncpu: Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz\nBenchmarkCprpc-4                   23352             51321 ns/op             328 B/op         11 allocs/op\nBenchmarkCprpcJSON-4               17560             64298 ns/op             336 B/op         13 allocs/op\nBenchmarkCprpcMsgpack-4            13821             83964 ns/op             328 B/op         11 allocs/op\nBenchmarkCprpcPool-4               15102             74708 ns/op            1070 B/op         22 allocs/op\nBenchmarkCprpcPoolJSON-4           19048             62061 ns/op             368 B/op         13 allocs/op\nBenchmarkCprpcPoolMsgpack-4        12912             86324 ns/op             360 B/op         12 allocs/op\nBenchmarkNetRpc-4                  18945             62589 ns/op             358 B/op         12 allocs/op\nPASS\nok      github.com/hmgle/cprpc  13.357s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmgle%2Fcprpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmgle%2Fcprpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmgle%2Fcprpc/lists"}