{"id":22683518,"url":"https://github.com/notedit/msgpack-oocrpc","last_synced_at":"2025-03-29T14:41:06.341Z","repository":{"id":3688734,"uuid":"4759053","full_name":"notedit/msgpack-oocrpc","owner":"notedit","description":"oocrpc with the msgpack ","archived":false,"fork":false,"pushed_at":"2012-06-27T15:17:54.000Z","size":104,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-04T15:43:46.506Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/notedit.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}},"created_at":"2012-06-23T06:55:29.000Z","updated_at":"2014-11-02T00:19:09.000Z","dependencies_parsed_at":"2022-09-15T16:11:42.813Z","dependency_job_id":null,"html_url":"https://github.com/notedit/msgpack-oocrpc","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/notedit%2Fmsgpack-oocrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notedit%2Fmsgpack-oocrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notedit%2Fmsgpack-oocrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notedit%2Fmsgpack-oocrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notedit","download_url":"https://codeload.github.com/notedit/msgpack-oocrpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246200300,"owners_count":20739563,"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":[],"created_at":"2024-12-09T21:12:24.818Z","updated_at":"2025-03-29T14:41:06.322Z","avatar_url":"https://github.com/notedit.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# msgpack-oocrpc\n\nThis is msgpack-oocrpc, a rpc based on msgpack, you can call the remote golang service from the python client.\n\nso you can write the webapp's frontend with python(django tornado flask), write the webapp's backend with go.\n\n# go rpc server:\n\n```go\npackage main\n                                                                                                                            \nimport (\n    \"errors\"\n    \"github.com/notedit/msgpack-oocrpc/rpc\"\n)\n\ntype Args struct {\n    A, B int\n}\n\ntype Reply struct {\n    C int\n}\n\ntype Arith int\n\nfunc (t *Arith) Add(args *Args, reply *Reply) error {\n    reply.C = args.A + args.B\n    return nil\n}\n\nfunc (t *Arith) Mul(args *Args, reply *Reply) error {\n    reply.C = args.A * args.B\n    return nil\n}\n\nfunc (t *Arith) Div(args *Args, reply *Reply) error {\n    if args.B == 0 {\n        return rpc.BackendError{\"InternalError\", \"divide by zero\"}\n    }\n    reply.C = args.A / args.B\n    return nil\n}\n\n\nfunc (t *Arith) Error(args *Args, reply *Reply) error {\n    panic(\"ERROR\")\n}\n\nfunc (t *Arith) NError(args *Args, reply *Reply) error {\n    return errors.New(\"normalerror\")\n}\n\nfunc main() {\n    newServer := rpc.NewServer(\"localhost\", 9091)\n    newServer.Register(new(Arith))\n    newServer.Serv()\n}    \n```\n\n# go rpc client:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/notedit/msgpack-oocrpc/rpc\"\n)\n\ntype Args struct {\n    A, B int\n}\n\ntype Reply struct {\n    C int\n}\n\nfunc main() {\n    client := rpc.New(\"localhost:9090\")\n    // normal test\n    args := \u0026Args{7, 8}\n    reply := \u0026Reply{}\n\n    err := client.Call(\"Arith.Mul\", args, reply)\n    if err != nil {\n        fmt.Println(err.Error())\n    }\n\n    err = client.Call(\"Arith.Add\", args, reply)\n    if err != nil {\n        fmt.Println(err.Error())\n    }\n\n    // un exist method\n    err = client.Call(\"Arith.Notfound\", args, reply)\n    if err != nil {\n        fmt.Println(err.Error())\n    }\n    // un exist service\n    err = client.Call(\"Notfound.arith\", args, reply)\n    if err != nil {\n        fmt.Println(err.Error())\n    }\n    // test error \n    args = \u0026Args{7, 0}\n    reply = \u0026Reply{}\n\n    err = client.Call(\"Arith.Div\", args, reply)\n    if err != nil {\n        fmt.Println(err.Error())\n    }\n\n    // test panic\n    args = \u0026Args{7, 8}\n    reply = \u0026Reply{}\n\n    err = client.Call(\"Arith.Error\", args, reply)\n    if err != nil {\n        fmt.Println(err.Error())\n    }\n}                \n```\n\n# python rpc client:\n\n```python\nfrom client import RpcClient\n\nclient = RpcClient(host='localhost',port=9090)                                                                          \nret = client.Add({'A':7,'B':8})\nprint 'Add',ret\n\nret = client.Mul({'A':7,'B':8})\nprint 'Mul',ret\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotedit%2Fmsgpack-oocrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotedit%2Fmsgpack-oocrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotedit%2Fmsgpack-oocrpc/lists"}