{"id":16517606,"url":"https://github.com/rfyiamcool/grpcall","last_synced_at":"2025-03-16T19:30:49.781Z","repository":{"id":57488072,"uuid":"171452993","full_name":"rfyiamcool/grpcall","owner":"rfyiamcool","description":"🦀 Easy request GRPC Server with reflect mode","archived":false,"fork":false,"pushed_at":"2023-03-15T08:01:02.000Z","size":72,"stargazers_count":146,"open_issues_count":2,"forks_count":36,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-15T15:54:29.150Z","etag":null,"topics":["grpc","grpc-reflect"],"latest_commit_sha":null,"homepage":"http://xiaorui.cc","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rfyiamcool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-02-19T10:23:08.000Z","updated_at":"2024-11-25T02:21:42.000Z","dependencies_parsed_at":"2024-06-20T17:29:05.890Z","dependency_job_id":"96ac632b-9612-4876-b0bb-b4ceec3330d1","html_url":"https://github.com/rfyiamcool/grpcall","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/rfyiamcool%2Fgrpcall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfyiamcool%2Fgrpcall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfyiamcool%2Fgrpcall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfyiamcool%2Fgrpcall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rfyiamcool","download_url":"https://codeload.github.com/rfyiamcool/grpcall/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826780,"owners_count":20354220,"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":["grpc","grpc-reflect"],"created_at":"2024-10-11T16:32:52.908Z","updated_at":"2025-03-16T19:30:49.465Z","avatar_url":"https://github.com/rfyiamcool.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grpcall\n\ngrpcall is a client library easy request GRPC Server with reflect mode, then it make grpc proxy mode middleware, like grpc-gateway.\n\nuse GRPC's reflect mode to request GRPC Server. grpcall support FileDescriptorSet and grpc/reflection mode.\n\n![](design.jpg)\n\n`some code refer: protoreflect, grpcurl`\n\n## Feature\n\n* support event hook\n* dynamic request GRPC Server with reflect mode. \n* dynamic convert protobuf to json and json to protobuf\n* grpc client manager\n* support stream\n* recv system signal to update new descriptor.\n* ...\n\n## Usage\n\n```go\ngrpcall.SetProtoSetFiles(\"helloworld.protoset\")\ngrpcall.InitDescSource()\n\nvar handler = DefaultEventHandler{}\nvar sendBody string\n\ngrpcEnter, err := grpcall.New(\n    grpcall.SetHookHandler(\u0026handler),\n)\ngrpcEnter.Init()\n\nsendBody = `{\"name\": \"xiaorui.cc\"}`\nres, err := grpcEnter.Call(\"127.0.0.1:50051\", \"helloworld.Greeter\", \"SayHello\", sendBody)\nfmt.Printf(\"%+v \\n\", res)\nfmt.Println(\"req/reply return err: \", err)\n\nsendBody = `{\"msg\": \"hehe world\"}`\nres, err = grpcEnter.Call(\"127.0.0.1:50051\", \"helloworld.SimpleService\", \"SimpleRPC\", sendBody)\nfmt.Printf(\"%+v \\n\", res)\nfmt.Println(\"stream return err: \", err)\n\nwg := sync.WaitGroup{}\nwg.Add(2)\n\ngo func() {\n    defer wg.Done()\n    for {\n        body := fmt.Sprintf(`{\"msg\": \"hehe world %s\"}`, time.Now().String())\n        select {\n        case res.SendChan \u003c- []byte(body):\n            // fmt.Println(\"send\", body)\n            time.Sleep(3 * time.Second)\n\n        case \u003c-res.DoneChan:\n            return\n\n        default:\n            return\n        }\n    }\n}()\n\ngo func() {\n    defer wg.Done()\n\n    for {\n        select {\n        case msg, ok := \u003c-res.ResultChan:\n            fmt.Println(\"recv data:\", msg, ok)\n        case err := \u003c-res.DoneChan:\n            fmt.Println(\"done chan: \", err)\n            return\n        }\n    }\n}()\n\nwg.Wait()\n\ntype DefaultEventHandler struct {\n    sendChan chan []byte\n}\n\nfunc (h *DefaultEventHandler) OnReceiveData(md metadata.MD, resp string, respErr error) {\n}\n\nfunc (h *DefaultEventHandler) OnReceiveTrailers(stat *status.Status, md metadata.MD) {\n}\n```\n\n## Test Example\n\n1. start grpc server\n\n```\ncd testing; go run test_server.go\n```\n\n2. start grpcall client\n\n```\ncd testing; go run test_grpcall_client.go\n```\n\n## Protoset Files\n\nProtoset files contain binary encoded `google.protobuf.FileDescriptorSet` protos. To create\na protoset file, invoke `protoc` with the `*.proto` files that define the service:\n\n```shell\nprotoc --proto_path=. \\\n    --descriptor_set_out=myservice.protoset \\\n    --include_imports \\\n    my/custom/server/service.proto\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frfyiamcool%2Fgrpcall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frfyiamcool%2Fgrpcall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frfyiamcool%2Fgrpcall/lists"}