{"id":16316772,"url":"https://github.com/makasim/jsonrpc","last_synced_at":"2025-05-13T15:30:52.366Z","repository":{"id":57706301,"uuid":"501993276","full_name":"makasim/jsonrpc","owner":"makasim","description":"TCP based JSON RPC 1.0 Client\\Server","archived":false,"fork":false,"pushed_at":"2022-06-15T20:20:49.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-16T19:48:22.665Z","etag":null,"topics":["client","golang","jsonrpc","server"],"latest_commit_sha":null,"homepage":"","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/makasim.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}},"created_at":"2022-06-10T10:05:26.000Z","updated_at":"2023-07-27T05:49:24.000Z","dependencies_parsed_at":"2022-08-24T13:00:29.046Z","dependency_job_id":null,"html_url":"https://github.com/makasim/jsonrpc","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/makasim%2Fjsonrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makasim%2Fjsonrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makasim%2Fjsonrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makasim%2Fjsonrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makasim","download_url":"https://codeload.github.com/makasim/jsonrpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253970175,"owners_count":21992437,"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":["client","golang","jsonrpc","server"],"created_at":"2024-10-10T22:05:33.738Z","updated_at":"2025-05-13T15:30:52.336Z","avatar_url":"https://github.com/makasim.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TCP based JSON RPC 1.0 Client\\Server\n\nThe package combines TCP connections management from [valyala/fasthttp](https://github.com/valyala/fasthttp) and\nGo's standard [jsonrpc codec](https://pkg.go.dev/net/rpc/jsonrpc).\n\nHere is a simple example. A server wishes to export an object of type Arith:\n\n```go\npackage server\n\nimport \"errors\"\n\ntype Args struct {\n\tA, B int\n}\n\ntype Quotient struct {\n\tQuo, Rem int\n}\n\ntype Arith int\n\nfunc (t *Arith) Multiply(args *Args, reply *int) error {\n\t*reply = args.A * args.B\n\treturn nil\n}\n\nfunc (t *Arith) Divide(args *Args, quo *Quotient) error {\n\tif args.B == 0 {\n\t\treturn errors.New(\"divide by zero\")\n\t}\n\tquo.Quo = args.A / args.B\n\tquo.Rem = args.A % args.B\n\treturn nil\n}\n```\n\nThe server calls:\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"net\"\n\t\n\t\"github.com/makasim/jsonrpc\"\n\n\t\"server\"\n)\n\nfunc main() {\n\ts := \u0026jsonrpc.Server{\n\t\tReceivers: []interface{}{\n\t\t\t\u0026server.Arith{},\n\t\t},\n\t}\n\t\n\tif err := s.ListenAndServe(\":1234\"); err != nil {\n\t\tlog.Fatalf(\"serve: %s\", err)\n\t}\n}\n\n\n```\n\n\nAt this point, clients can see a service \"Arith\" with methods \"Arith.Multiply\" and \"Arith.Divide\". \nTo invoke one, a client does a remote call:\n\nClient:\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\n\t\"github.com/makasim/jsonrpc\"\n\t\n\t\"server\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\targs := \u0026server.Args{7,8}\n\tvar reply int\n\t\n\tc := \u0026jsonrpc.Client{}\n\t\n\terr := c.Call(ctx, \"127.0.0.1:9999\", \"FooService.Func\", args, \u0026reply)\n\tif err != nil {\n\t\tlog.Fatal(\"call error:\", err)\n\t}\n\t\n\tlog.Println(reply)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakasim%2Fjsonrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakasim%2Fjsonrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakasim%2Fjsonrpc/lists"}