{"id":27063602,"url":"https://github.com/rpcx-ecosystem/rpcx-gateway","last_synced_at":"2025-04-05T16:01:48.392Z","repository":{"id":38022471,"uuid":"112607312","full_name":"rpcxio/rpcx-gateway","owner":"rpcxio","description":"http gateway for rpcx services. Clients in any programming languages can call them","archived":false,"fork":false,"pushed_at":"2023-06-02T02:21:08.000Z","size":9160,"stargazers_count":203,"open_issues_count":3,"forks_count":41,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-04-18T12:29:44.064Z","etag":null,"topics":["cross-platform","gateway","microservice","microservices","rpc","rpcx","service-mesh","sidecar"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rpcxio.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}},"created_at":"2017-11-30T12:11:09.000Z","updated_at":"2024-04-04T11:01:02.000Z","dependencies_parsed_at":"2023-07-13T09:55:58.176Z","dependency_job_id":null,"html_url":"https://github.com/rpcxio/rpcx-gateway","commit_stats":null,"previous_names":["rpcx-ecosystem/rpcx-gateway"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpcxio%2Frpcx-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpcxio%2Frpcx-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpcxio%2Frpcx-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpcxio%2Frpcx-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rpcxio","download_url":"https://codeload.github.com/rpcxio/rpcx-gateway/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361593,"owners_count":20926641,"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":["cross-platform","gateway","microservice","microservices","rpc","rpcx","service-mesh","sidecar"],"created_at":"2025-04-05T16:01:33.310Z","updated_at":"2025-04-05T16:01:48.380Z","avatar_url":"https://github.com/rpcxio.png","language":"Go","funding_links":[],"categories":["sidecar"],"sub_categories":[],"readme":"# rpcx-gateway\n[rpcx-gateway](https://github.com/rpcxio/rpcx-gateway) is a http gateway for [rpcx](https://github.com/smallnest/rpcx) services.\n\n[rpcx](https://github.com/smallnest/rpcx) is a fast rpc framework. Faster, more features.\n\nYou can write rpc http clients in any programming languages such as Java、Python、C#、Node.js、Php、C\\C++、Rust and others. See [examples](https://github.com/rpcxio/rpcx-gateway/blob/master/examples/README.md)\n\n## Deployment models\n\nThere are two deployment modes: **Gateway** and **Agent**。\n\n### Gateway\n\n![](doc/gateway.png)\n\nYou can deploy this as gateway model. Gateway is running at independent servers. Clients sends http requests to gateways, and gateways translate http requests into raw rpcx requests. And then gateways send raw rpcx requests to rpcx services.\n\nwhen gateways receive rpcx responses, they translates rpcx responses into http responses and return clients.\n\nYou can scale gateway easily because it is stateless.\n\nIt works like a http load balancer.\n\n\n### Agent\n\n![](doc/agent.png)\n\n\nYou can also deploy this as agent model. Agents are deploy with clients. They are installed as a daemon application in node of clients. If there are multiple clients in one node, you only need to install one agent.\n\nClients send http requests to their local agent. The local agent translate http requests into rpcx requests, send rpcx requests to rpcx services, translate rpcx responses into http ressponses.\n\nIt works like service mesh.\n\n\n## Protocol\n\nYou can send a http request in any programming languages. You must set some extra http headers in requests.\n\n- X-RPCX-Version: rpcx version\n- X-RPCX-MesssageType: set 0 as request\n- X-RPCX-Heartbeat: is heartbeat request or not, false in default.\n- X-RPCX-Oneway: is one-way request or not, false in default.\n- X-RPCX-SerializeType: 0 as raw bytes, 1 as JSON, 2 as protobuf, 3 as msgpack\n- X-RPCX-MessageID: message ID, uint64 type\n- X-RPCX-ServicePath: service path\n- X-RPCX-ServiceMethod: service method\n- X-RPCX-Meta: extra metadata\n\nFor the http response, there are some extra http headers:\n\n- X-RPCX-Version: rpcx version\n- X-RPCX-MesssageType: 1 as response\n- X-RPCX-Heartbeat: is heartbeat response or not\n- X-RPCX-MessageStatusType:  Error or Normal. Error means there is call failure\n- X-RPCX-SerializeType: 0 as raw bytes, 1 as JSON, 2 as protobuf, 3 as msgpack\n- X-RPCX-MessageID: message ID, uint64 type\n- X-RPCX-ServicePath: service path\n- X-RPCX-ServiceMethod: service method\n- X-RPCX-Meta: extra metadata\n- X-RPCX-ErrorMessage: error message if X-RPCX-MessageStatusType is Error\n\n\n## Example\n\nThere is a golang http client example:\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/rpcxio/rpcx-gateway\"\n\n\t\"github.com/smallnest/rpcx/codec\"\n)\n\ntype Args struct {\n\tA int\n\tB int\n}\n\ntype Reply struct {\n\tC int\n}\n\nfunc main() {\n\tcc := \u0026codec.MsgpackCodec{}\n\n    // request \n\targs := \u0026Args{\n\t\tA: 10,\n\t\tB: 20,\n\t}\n\tdata, _ := cc.Encode(args)\n\n\treq, err := http.NewRequest(\"POST\", \"http://127.0.0.1:9981/\", bytes.NewReader(data))\n\tif err != nil {\n\t\tlog.Fatal(\"failed to create request: \", err)\n\t\treturn\n    }\n    \n    // set extra headers\n\th := req.Header\n\th.Set(gateway.XSerializeType, \"3\")\n\th.Set(gateway.XServicePath, \"Arith\")\n\th.Set(gateway.XServiceMethod, \"Mul\")\n\n    // send to gateway\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tlog.Fatal(\"failed to call: \", err)\n\t}\n\tdefer res.Body.Close()\n\n\t// handle http response\n\treplyData, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\tlog.Fatal(\"failed to read response: \", err)\n\t}\n\n    // parse reply\n\treply := \u0026Reply{}\n\terr = cc.Decode(replyData, reply)\n\tif err != nil {\n\t\tlog.Fatal(\"failed to decode reply: \", err)\n\t}\n\n\tlog.Printf(\"%d * %d = %d\", args.A, args.B, reply.C)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpcx-ecosystem%2Frpcx-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frpcx-ecosystem%2Frpcx-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpcx-ecosystem%2Frpcx-gateway/lists"}