{"id":15109538,"url":"https://github.com/wanzo-mini/mini-rpc","last_synced_at":"2026-01-11T03:33:56.904Z","repository":{"id":37375577,"uuid":"432077195","full_name":"wanzo-mini/mini-rpc","owner":"wanzo-mini","description":"🚀 Fast, stable, mini RPC framework based on protocol buffer","archived":true,"fork":false,"pushed_at":"2025-01-24T14:16:01.000Z","size":112,"stargazers_count":1059,"open_issues_count":0,"forks_count":172,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-09-01T12:50:10.605Z","etag":null,"topics":["golang","protobuf","rpc"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wanzo-mini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-11-26T06:30:44.000Z","updated_at":"2025-08-31T01:44:51.000Z","dependencies_parsed_at":"2024-06-18T20:02:14.649Z","dependency_job_id":"0d2d1d58-0a31-449e-898c-20794b813afe","html_url":"https://github.com/wanzo-mini/mini-rpc","commit_stats":{"total_commits":70,"total_committers":7,"mean_commits":10.0,"dds":0.5142857142857142,"last_synced_commit":"687f5fa41e78efebe87b5838ea09afb56be1f4a0"},"previous_names":["wanzoma/tinyrpc","zehuamama/tinyrpc","hyman-m/tinyrpc","wanzo-mini/mini-rpc","cloudmzh/tinyrpc"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/wanzo-mini/mini-rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanzo-mini%2Fmini-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanzo-mini%2Fmini-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanzo-mini%2Fmini-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanzo-mini%2Fmini-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wanzo-mini","download_url":"https://codeload.github.com/wanzo-mini/mini-rpc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanzo-mini%2Fmini-rpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277218849,"owners_count":25781446,"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-09-27T02:00:08.978Z","response_time":73,"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":["golang","protobuf","rpc"],"created_at":"2024-09-25T23:03:27.079Z","updated_at":"2025-09-27T10:31:24.549Z","avatar_url":"https://github.com/wanzo-mini.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mini-rpc\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/wanzo-mini/mini-rpc)](https://goreportcard.com/report/github.com/wanzo-mini/mini-rpc)\u0026nbsp;![GitHub top language](https://img.shields.io/github/languages/top/wanzo-mini/mini-rpc)\u0026nbsp;![GitHub](https://img.shields.io/github/license/wanzo-mini/mini-rpc)\u0026nbsp;[![CodeFactor](https://www.codefactor.io/repository/github/wanzo-mini/mini-rpc/badge)](https://www.codefactor.io/repository/github/wanzo-mini/mini-rpc)\u0026nbsp;[![codecov](https://codecov.io/gh/wanzoma/mini-rpc/branch/main/graph/badge.svg)](https://codecov.io/gh/wanzo-mini/mini-rpc)\u0026nbsp; ![go_version](https://img.shields.io/badge/go%20version-1.17-yellow)\n\nmini-rpc is a high-performance RPC framework based on `protocol buffer` encoding. It is based on `net/rpc` and supports multiple compression formats (`gzip`, `snappy`, `zlib`).\n\nLanguage\u0026nbsp;\u0026nbsp;English\n\n## Install\n\n\n- install `protoc` at first :http://github.com/google/protobuf/releases\n\n- install `protoc-gen-go` and `protoc-gen-mini-rpc`:\n\n```\ngo install github.com/golang/protobuf/protoc-gen-go@latest\ngo install github.com/wanzoma/mini-rpc/protoc-gen-mini-rpc@latest\n```\n\n## Quick Start\nFisrt, create a demo and import the mini-rpc package:\n```shell\n\u003e go mod init demo\n\u003e go get github.com/wanzo-mini/mini-rpc\n```\nunder the path of the project, create a protobuf file `arith.proto`:\n```protobuf\nsyntax = \"proto3\";\n\npackage message;\noption go_package=\"/message\";\n\n// ArithService Defining Computational Digital Services\nservice ArithService {\n  // Add addition\n  rpc Add(ArithRequest) returns (ArithResponse);\n  // Sub subtraction\n  rpc Sub(ArithRequest) returns (ArithResponse);\n  // Mul multiplication\n  rpc Mul(ArithRequest) returns (ArithResponse);\n  // Div division\n  rpc Div(ArithRequest) returns (ArithResponse);\n}\n\nmessage ArithRequest {\n  int32 a = 1;\n  int32 b = 2;\n}\n\nmessage ArithResponse {\n  int32 c = 1;\n}\n```\nan arithmetic operation service is defined here, using `protoc` to generate code:\n```shell\n\u003e protoc --mini-rpc_out=. arith.proto --go_out=. arith.proto\n```\nat this time, two files will be generated in the directory `message`: `arith.pb.go` and `arith.svr.go`\n\nyou can also use\n```shell\n\u003e protoc --mini-rpc_out=gen-cli=true:. arith.proto --go_out=. arith.proto\n```\nto generate `arith.cli.go`, this file make it easier to call the server.\n\n\nthe code of `arith.svr.go` is shown below:\n```go\n// Code generated by protoc-gen-mini-rpc.\n\npackage message\n\n// ArithService Defining Computational Digital Services\ntype ArithService struct{}\n\n// Add addition\nfunc (this *ArithService) Add(args *ArithRequest, reply *ArithResponse) error {\n\t// define your service ...\n\treturn nil\n}\n\n// Sub subtraction\nfunc (this *ArithService) Sub(args *ArithRequest, reply *ArithResponse) error {\n\t// define your service ...\n\treturn nil\n}\n\n// Mul multiplication\nfunc (this *ArithService) Mul(args *ArithRequest, reply *ArithResponse) error {\n\t// define your service ...\n\treturn nil\n}\n\n// Div division\nfunc (this *ArithService) Div(args *ArithRequest, reply *ArithResponse) error {\n\t// define your service ...\n\treturn nil\n}\n```\nwe need to define our services. \n\nFinally, under the path of the project, we create a file named `main.go`, the code is shown below:\n```go\npackage main\n\nimport (\n\t\"demo/message\"\n\t\"log\"\n\t\"net\"\n\n\t\"github.com/wanzo-mini/mini-rpc\"\n)\n\nfunc main() {\n\tlis, err := net.Listen(\"tcp\", \":8082\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tserver := mini-rpc.NewServer()\n\tserver.RegisterName(\"ArithService\", new(message.ArithService))\n\tserver.Serve(lis)\n}\n```\na mini-rpc server is completed.\n\n## Client\nWe can create a mini-rpc client and call it synchronously with the `Add` function:\n```go\nimport (\n        \"demo/message\"\n\t\"github.com/wanzo-mini/mini-rpc\"\n)\n...\n\nconn, err := net.Dial(\"tcp\", \":8082\")\nif err != nil {\n\tlog.Fatal(err)\n}\ndefer conn.Close()\nclient := mini-rpc.NewClient(conn)\nresq := message.ArithRequest{A: 20, B: 5}\nresp := message.ArithResponse{}\nerr = client.Call(\"ArithService.Add\", \u0026resq, \u0026resp)\nlog.Printf(\"Arith.Add(%v, %v): %v ,Error: %v\", resq.A, resq.B, resp.C, err)\n```\nyou can also call asynchronously, which will return a channel of type *rpc.Call:\n```go\n\nresult := client.AsyncCall(\"ArithService.Add\", \u0026resq, \u0026resp)\nselect {\ncase call := \u003c-result:\n\tlog.Printf(\"Arith.Add(%v, %v): %v ,Error: %v\", resq.A, resq.B, resp.C, call.Error)\ncase \u003c-time.After(100 * time.Microsecond):\n\tlog.Fatal(\"time out\")\n}\n```\nof course, you can also compress with three supported formats `gzip`, `snappy`, `zlib`:\n```go\nimport \"github.com/wanzo-mini/mini-rpc/compressor\"\n\n...\nclient := mini-rpc.NewClient(conn, mini-rpc.WithCompress(compressor.Gzip))\n\n```\n## Custom Serializer\nIf you want to customize the serializer, you must implement the `Serializer` interface:\n```go\ntype Serializer interface {\n\tMarshal(message interface{}) ([]byte, error)\n\tUnmarshal(data []byte, message interface{}) error\n}\n```\n`JsonSerializer` is a serializer based Json:\n```go\ntype JsonSerializer struct{}\n\nfunc (_ JsonSerializer) Marshal(message interface{}) ([]byte, error) {\n\treturn json.Marshal(message)\n}\n\nfunc (_ JsonSerializer) Unmarshal(data []byte, message interface{}) error {\n\treturn json.Unmarshal(data, message)\n}\n```\nmoving on, we create a HelloService with the following code:\n```go\ntype HelloRequest struct {\n\tReq string `json:\"req\"`\n}\n\ntype HelloResponce struct {\n\tResp string `json:\"resp\"`\n}\n\ntype HelloService struct{}\n\nfunc (_ *HelloService) SayHello(args *HelloRequest, reply *HelloResponce) error {\n\treply.Resp = args.Req\n\treturn nil\n}\n\n```\nfinally, we need to set the serializer on the rpc server:\n```go\nfunc main() {\n\tlis, err := net.Listen(\"tcp\", \":8082\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tserver := mini-rpc.NewServer(mini-rpc.WithSerializer(JsonSerializer{}))\n\tserver.Register(new(HelloService))\n\tserver.Serve(lis)\n}\n```\na rpc server based on json serializer is completed.\n\nRemember that when the rpc client calls the service, it also needs to set the serializer:\n```go\nmini-rpc.NewClient(conn,mini-rpc.WithSerializer(JsonSerializer{}))\n```\n## Contributing\n\nIf you are intersted in contributing to mini-rpc, please see here: [CONTRIBUTING](https://github.com/wanzo-mini/mini-rpc/blob/main/CONTRIBUTING.md)\n\n## License\n\nmini-rpc is licensed under the term of the [BSD 2-Clause License](https://github.com/wanzo-mini/mini-rpc/blob/main/LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanzo-mini%2Fmini-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwanzo-mini%2Fmini-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanzo-mini%2Fmini-rpc/lists"}