{"id":18345825,"url":"https://github.com/hyperf/roc","last_synced_at":"2026-02-01T12:11:05.156Z","repository":{"id":57659516,"uuid":"464358131","full_name":"hyperf/roc","owner":"hyperf","description":"Channel driven multiplexing connection for Golang.","archived":false,"fork":false,"pushed_at":"2023-03-09T04:26:26.000Z","size":73,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-03T17:27:03.839Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/hyperf.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},"funding":{"open_collective":"hyperf","custom":"https://hyperf.wiki/#/zh-cn/donate"}},"created_at":"2022-02-28T06:02:20.000Z","updated_at":"2023-07-25T14:54:56.000Z","dependencies_parsed_at":"2024-06-21T16:41:35.053Z","dependency_job_id":null,"html_url":"https://github.com/hyperf/roc","commit_stats":null,"previous_names":["hyperf/gomul"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/hyperf/roc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Froc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Froc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Froc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Froc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperf","download_url":"https://codeload.github.com/hyperf/roc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Froc/sbom","scorecard":{"id":475288,"data":{"date":"2025-08-11","repo":{"name":"github.com/hyperf/roc","commit":"80cff25b6992d44b8a5bb86e3b7eb6444a7c0863"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/hyperf/roc/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/hyperf/roc/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/hyperf/roc/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/hyperf/roc/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/hyperf/roc/test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/hyperf/roc/test.yml/main?enable=pin","Warn: containerImage not pinned by hash: examples/json_rpc/Dockerfile:1","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: github.com/hyperf/.github/SECURITY.md:1","Info: Found linked content: github.com/hyperf/.github/SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/hyperf/.github/SECURITY.md:1","Info: Found text in security policy: github.com/hyperf/.github/SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0603 / GHSA-hp87-p4gw-j4gq"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T15:07:51.917Z","repository_id":57659516,"created_at":"2025-08-19T15:07:51.918Z","updated_at":"2025-08-19T15:07:51.918Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":282007172,"owners_count":26598242,"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","status":"online","status_checked_at":"2025-10-31T02:00:07.401Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-05T21:09:35.917Z","updated_at":"2025-10-31T15:04:55.113Z","avatar_url":"https://github.com/hyperf.png","language":"Go","readme":"# Channel driven multiplexing connection\n\n[![Test](https://github.com/hyperf/roc/actions/workflows/test.yml/badge.svg)](https://github.com/hyperf/roc/actions/workflows/test.yml)\n\n## How to install\n\n```shell\ngo get github.com/hyperf/roc\n```\n\n## How to use\n\n[roc-skeleton](https://github.com/limingxinleo/roc-skeleton)\n\n### For Server\n\n- action/foo_save_action.go\n\n```go\npackage action\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"github.com/hyperf/roc\"\n\t\"github.com/hyperf/roc/exception\"\n\t\"github.com/hyperf/roc/formatter\"\n\t\"github.com/hyperf/roc/serializer\"\n)\n\ntype FooSaveAction struct {\n}\n\ntype FooSaveInput struct {\n\tName   string `json:\"name\"`\n\tGender int    `json:\"gender\"`\n}\ntype FooSaveRequest struct {\n\tID    int\n\tInput FooSaveInput\n}\n\nfunc (m *FooSaveRequest) UnmarshalJSON(bytes []byte) error {\n\tvar raw []json.RawMessage\n\tif err := json.Unmarshal(bytes, \u0026raw); err != nil {\n\t\treturn err\n\t}\n\n\tif err := json.Unmarshal(raw[0], \u0026m.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif err := json.Unmarshal(raw[1], \u0026m.Input); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\ntype FooSaveResult struct {\n\tIsSuccess bool `json:\"is_success\"`\n}\n\nfunc (f *FooSaveAction) getRequest(packet *roc.Packet, serializer serializer.SerializerInterface) (*FooSaveRequest, exception.ExceptionInterface) {\n\treq := \u0026formatter.JsonRPCRequest[*FooSaveRequest, any]{}\n\n\tif err := serializer.UnSerialize(packet.GetBody(), req); err != nil {\n\t\treturn nil, exception.NewDefaultException(err.Error())\n\t}\n\n\treturn req.Data, nil\n}\n\nfunc (f *FooSaveAction) Handle(packet *roc.Packet, serializer serializer.SerializerInterface) (any, exception.ExceptionInterface) {\n\trequest, e := f.getRequest(packet, serializer)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\n\tfmt.Println(request.ID, request.Input.Name)\n\n\treturn \u0026FooSaveResult{IsSuccess: true}, nil\n}\n\n```\n\n- main.go\n\n```go\npackage main\n\nimport (\n\t\"github.com/hyperf/roc\"\n\t\"github.com/hyperf/roc/examples/json_rpc/action\"\n\t\"github.com/hyperf/roc/exception\"\n\t\"github.com/hyperf/roc/formatter\"\n\t\"github.com/hyperf/roc/router\"\n\t\"github.com/hyperf/roc/server\"\n)\n\nfunc SetUpRouters() *router.SimpleRouter {\n\tr := router.NewSimpleRouter()\n\tr.Add(\"/foo/save\", \u0026action.FooSaveAction{})\n\treturn r\n}\n\nfunc main() {\n\tr := SetUpRouters()\n\n\thandler := server.NewTcpServerHandler(func(route *formatter.JsonRPCRoute, packet *roc.Packet, server *server.TcpServer) (any, exception.ExceptionInterface) {\n\t\taction, ok := r.Routes[route.Path]\n\t\tif !ok {\n\t\t\treturn nil, \u0026exception.Exception{Code: exception.NOT_FOUND, Message: \"The route is not defined.\"}\n\t\t}\n\n\t\treturn action.Handle(packet, server.Serializer)\n\t})\n\n\tserv := server.NewTcpServer(\"0.0.0.0:9501\", handler)\n\n\tserv.Start()\n}\n\n```\n\n### For Client\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\tcli \"github.com/hyperf/roc/client\"\n\t\"github.com/hyperf/roc/formatter\"\n\t\"time\"\n)\n\ntype FooSaveInput struct {\n\tName   string `json:\"name\"`\n\tGender int    `json:\"gender\"`\n}\n\ntype FooSaveRequest struct {\n\tID    int\n\tInput *FooSaveInput\n}\n\ntype FooSaveResult struct {\n\tIsSuccess bool `json:\"is_success\"`\n}\n\ntype LocalAddr struct {\n}\n\nfunc (l LocalAddr) Network() string {\n\treturn \"tcp\"\n}\n\nfunc (l LocalAddr) String() string {\n\treturn \"127.0.0.1:9501\"\n}\n\nfunc (f *FooSaveRequest) MarshalJSON() ([]byte, error) {\n\treturn formatter.FormatRequestToByte(f)\n}\n\nvar client *cli.Client\n\nfunc init() {\n\tvar err error\n\tclient, err = cli.NewAddrClient(\u0026LocalAddr{})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n}\nfunc main() {\n\treq := FooSaveRequest{ID: 1, Input: \u0026FooSaveInput{Name: \"limx\", Gender: 1}}\n\tid, _ := client.SendRequest(\"/foo/save\", \u0026req)\n\n\tret := \u0026formatter.JsonRPCResponse[FooSaveResult, any]{}\n\terr := client.Recv(id, ret, cli.NewDefaultRecvOption())\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\tfmt.Println(ret.Result.IsSuccess)\n\n\tfor {\n\t\treq = FooSaveRequest{ID: 1, Input: \u0026FooSaveInput{Name: \"error\", Gender: 1}}\n\t\tid, _ = client.SendRequest(\"/foo/save\", \u0026req)\n\n\t\tret = \u0026formatter.JsonRPCResponse[FooSaveResult, any]{}\n\t\terr = client.Recv(id, ret, cli.NewDefaultRecvOption())\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\n\t\ttime.Sleep(time.Second)\n\t}\n}\n\n```\n\n## Related Repositories\n\n- [multiplex](https://github.com/hyperf/multiplex) Channel driven multiplexing connection for PHP.\n- [multiplex-socket](https://github.com/hyperf/multiplex-socket) Socket of channel driven multiplexing connection for PHP.\n- [rpc-multiplex](https://github.com/hyperf/rpc-multiplex) RPC of channel driven multiplexing connection for PHP.","funding_links":["https://opencollective.com/hyperf","https://hyperf.wiki/#/zh-cn/donate"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperf%2Froc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperf%2Froc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperf%2Froc/lists"}