{"id":21899000,"url":"https://github.com/ironsdu/drpc","last_synced_at":"2025-03-22T05:25:28.253Z","repository":{"id":144950866,"uuid":"98613886","full_name":"IronsDu/drpc","owner":"IronsDu","description":"泛型是什么?","archived":false,"fork":false,"pushed_at":"2023-02-14T13:39:32.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-27T06:14:52.906Z","etag":null,"topics":["rpc"],"latest_commit_sha":null,"homepage":"","language":"C++","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/IronsDu.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":"2017-07-28T05:58:21.000Z","updated_at":"2022-03-18T01:12:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"77708301-9bed-4f9a-b6cb-7a5e30615351","html_url":"https://github.com/IronsDu/drpc","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/IronsDu%2Fdrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronsDu%2Fdrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronsDu%2Fdrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronsDu%2Fdrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IronsDu","download_url":"https://codeload.github.com/IronsDu/drpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244911234,"owners_count":20530571,"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-28T14:36:51.986Z","updated_at":"2025-03-22T05:25:28.234Z","avatar_url":"https://github.com/IronsDu.png","language":"C++","readme":"# DRPC\n\nDRPC是一个C++ 智能RPC库,开发者只需要通过简单的接口定义服务名称以及服务实现函数，调用者直接使用参数进行调用，无需考虑封包和解包。\n\n## 例子\n\n使用本地进程内进行模拟测试（可以很简单的通过网络库发送请求即可跨机器使用此RPC库）\n```\n#include \u003ciostream\u003e\n\n#include \"RpcService.h\"\n#include \"JsonRpc.h\"\n#include \"MsgpackRpc.h\"\n\nusing namespace std;\nusing namespace dodo::rpc;\n\nint main()\n{\n    RpcService\u003cJsonProtocol\u003e rpc;\n\n    // 无论实参如何，call 总是返回 std::tuple\u003cstring, std::function\u003cvoid(string)\u003e\u003e\n    // 前者表示参数pack的json字符串，后者如果不为nullptr则表示回调函数（接收string，即可执行）\n\n    auto fuck1 = rpc.call(1, 2, \"hehe\", [](const std::string\u0026 value, int a) {\n        cout \u003c\u003c \"receive \" \u003c\u003c value \u003c\u003c endl;\n    });\n    auto fuck2 = rpc.call(\"haha\", 10);\n\n    // def 函数则直接返回一个包装函数 std::function\u003cvoid(string)\u003e，跟 call函数返回的tuple第二个值完全同类.\n    auto service = rpc.def([](const std::string\u0026 value, int a) {\n        cout \u003c\u003c \"receive \" \u003c\u003c value \u003c\u003c endl;\n    });\n\n    // 向 service 传递一个string，即可调用回调\n    service(std::get\u003c0\u003e(fuck2));\n    std::get\u003c1\u003e(fuck1)(std::get\u003c0\u003e(fuck2));\n\n    return 0;\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fironsdu%2Fdrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fironsdu%2Fdrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fironsdu%2Fdrpc/lists"}