{"id":19655484,"url":"https://github.com/weibocom/motan-go","last_synced_at":"2025-05-15T06:02:48.074Z","repository":{"id":26469277,"uuid":"108808743","full_name":"weibocom/motan-go","owner":"weibocom","description":"The golang implementation of Motan","archived":false,"fork":false,"pushed_at":"2025-04-27T02:28:44.000Z","size":2280,"stargazers_count":477,"open_issues_count":18,"forks_count":111,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-04-27T03:25:36.776Z","etag":null,"topics":["motan-go","motan-rpc","rpc-framework","service-mesh"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weibocom.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-30T06:06:39.000Z","updated_at":"2025-03-27T06:57:35.000Z","dependencies_parsed_at":"2023-11-09T13:26:20.218Z","dependency_job_id":"16b12725-11a1-486c-b07e-317790874008","html_url":"https://github.com/weibocom/motan-go","commit_stats":{"total_commits":479,"total_committers":24,"mean_commits":"19.958333333333332","dds":0.8204592901878914,"last_synced_commit":"f3ccb8bb3b42424fdc24ece02dcd39e55468f52b"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weibocom%2Fmotan-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weibocom%2Fmotan-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weibocom%2Fmotan-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weibocom%2Fmotan-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weibocom","download_url":"https://codeload.github.com/weibocom/motan-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254283336,"owners_count":22045140,"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":["motan-go","motan-rpc","rpc-framework","service-mesh"],"created_at":"2024-11-11T15:21:34.615Z","updated_at":"2025-05-15T06:02:48.057Z","avatar_url":"https://github.com/weibocom.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Motan-go\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/weibocom/motan/blob/master/LICENSE)\n[![codecov](https://codecov.io/gh/weibocom/motan-go/branch/master/graph/badge.svg?token=2s9DFOt9Y4)](https://codecov.io/gh/weibocom/motan-go)\n[![GoDoc](https://godoc.org/github.com/weibocom/motan-go?status.svg\u0026style=flat)](https://godoc.org/github.com/weibocom/motan-go)\n[![Go Report Card](https://goreportcard.com/badge/github.com/weibocom/motan-go)](https://goreportcard.com/report/github.com/weibocom/motan-go)\n\n\n# Overview\n[Motan][motan] is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.\n\nThis project is the golang Motan implementation. Provides golang motan server, motan client and motan agent. \nmotan agent is designed to support bio-proxy for any other language such as PHP, Python by motan2 protocol.\n\n# Features\n- Interactive with mulit language through motan2 protocol,such as Java, PHP.\n- Provides cluster support and integrate with popular service discovery services like [Consul][consul] or [Zookeeper][zookeeper]. \n- Supports advanced scheduling features like weighted load-balance, scheduling cross IDCs, etc.\n- Optimization for high load scenarios, provides high availability in production environment.\n- Supports both synchronous and asynchronous calls.\n\n# Quick Start\n\n## Installation\n\n```sh\ngo get -u -v github.com/weibocom/motan-go\n```\n\nThe quick start gives very basic example of running client and server on the same machine. For the detailed information about using and developing Motan, please jump to [Documents](#documents).\nthe demo case is in the main/ directory\n\n## Motan server\n\n1. Create serverdemo.yaml to config service\n\n```yaml\n#config of registries\nmotan-registry:\n  direct-registry: # registry id \n    protocol: direct   # registry type\n\n#conf of services\nmotan-service:\n  mytest-motan2:\n    path: com.weibo.motan.demo.service.MotanDemoService # e.g. service name for register\n    group: motan-demo-rpc\n    protocol: motan2\n    registry: direct-registry\n    serialization: simple\n    ref : \"main.MotanDemoService\"\n    export: \"motan2:8100\"\n```\n\n2. Write an implementation, create and start RPC Server.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\tmotan \"github.com/weibocom/motan-go\"\n)\n\nfunc main() {\n\trunServerDemo()\n}\n\nfunc runServerDemo() {\n\tmscontext := motan.GetMotanServerContext(\"serverdemo.yaml\") //get config by filename\n\tmscontext.RegisterService(\u0026MotanDemoService{}, \"\") // registry implement\n\tmscontext.Start(nil) // start server\n\ttime.Sleep(time.Second * 50000000)\n}\n\n// service implement\ntype MotanDemoService struct{}\n\nfunc (m *MotanDemoService) Hello(name string) string {\n\tfmt.Printf(\"MotanDemoService hello:%s\\n\", name)\n\treturn \"hello \" + name\n}\n```\n\n## Motan client\n\n1. Create clientdemo.yaml to config service for subscribe\n\n```yaml\n#config of registries\nmotan-registry:\n  direct-registry: # registry id \n    protocol: direct   # registry type. \n    host: 127.0.0.1 \n    port: 9981 \n\n#conf of refers\nmotan-refer:\n  mytest-motan2:\n    path: com.weibo.motan.demo.service.MotanDemoService # e.g. service name for subscribe\n    group: motan-demo-rpc # group name\n    protocol: motan2 # rpc protocol\n    registry: direct-registry\n    requestTimeout: 1000\n    serialization: simple\n    haStrategy: failover\n    loadbalance: roundrobin\n```\n\n2. Start call\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\tmotan \"github.com/weibocom/motan-go\"\n\tmotancore \"github.com/weibocom/motan-go/core\"\n)\n\nfunc main() {\n\trunClientDemo()\n}\n\nfunc runClientDemo() {\n\tmccontext := motan.GetClientContext(\"clientdemo.yaml\")\n\tmccontext.Start(nil)\n\tmclient := mccontext.GetClient(\"mytest-motan2\")\n\n\tvar reply string\n\terr := mclient.Call(\"hello\", []interface{}{\"Ray\"}, \u0026reply)  // sync call\n\tif err != nil {\n\t\tfmt.Printf(\"motan call fail! err:%v\\n\", err)\n\t} else {\n\t\tfmt.Printf(\"motan call success! reply:%s\\n\", reply)\n\t}\n\n\t// async call\n\tresult := mclient.Go(\"hello\", []interface{}{\"Ray\"}, \u0026reply, make(chan *motancore.AsyncResult, 1))\n\tres := \u003c-result.Done\n\tif res.Error != nil {\n\t\tfmt.Printf(\"motan async call fail! err:%v\\n\", res.Error)\n\t} else {\n\t\tfmt.Printf(\"motan async call success! reply:%+v\\n\", reply)\n\t}\n}\n\n```\n\n## Use agent. \n\nagent is not necessary for golang. it designed for interpreted languages such as PHP to support service governance\n\n1. Create clientdemo.yaml to config service for subscribe or register\n\n```yaml\n#config fo agent\nmotan-agent:\n  port: 9981 # agent serve port. \n  mport: 8002 # agent manage port \n\n#config of registries\nmotan-registry:\n  direct-registry: # registry id \n    protocol: direct   # registry type. will get instance from extFactory.\n    host: 127.0.0.1 # direct server ip.\n    port: 8100 #direct server port\n\n#conf of refers\nmotan-refer:\n  mytest-motan2:\n    path: com.weibo.motan.demo.service.MotanDemoService # e.g. service name for subscribe\n    group: motan-demo-rpc\n    protocol: motan2\n    registry: direct-registry\n    serialization: simple\n```\n\n2. Start Agent\n\n```go\npackage main\n\nimport motan \"github.com/weibocom/motan-go\"\n\nfunc main() {\n\trunAgentDemo()\n}\n\nfunc runAgentDemo() {\n\tagent := motan.NewAgent(nil)\n\tagent.ConfigFile = \"./agentdemo.yaml\"\n\tagent.StartMotanAgent()\n}\n```\n\n# Documents\n\n* [Wiki](https://github.com/weibocom/motan-go/wiki)\n* [Wiki(中文)](https://github.com/weibocom/motan-go/wiki/zh_overview)\n\n# Contributors\n\n* Ray([@rayzhang0603](https://github.com/rayzhang0603))\n* 周晶([@idevz](https://github.com/idevz))\n* xiaohutuer([@xiaohutuer](https://github.com/xiaohutuer))\n* Arthur Guo([@jealone](https://github.com/jealone))\n* huzhongx([@huzhongx](https://github.com/huzhongx))\n* dingzk([@dingzk](https://github.com/dingzk))\n* lion2luo([@lion2luo](https://github.com/lion2luo))\n* Zha([@Zha-Zha](https://github.com/Zha-Zha))\n* 李枨煊([@flyhope](https://github.com/flyhope))\n\n# License\n\nMotan is released under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).\n\n[motan]:https://github.com/weibocom/motan\n[consul]:http://www.consul.io\n[zookeeper]:http://zookeeper.apache.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweibocom%2Fmotan-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweibocom%2Fmotan-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweibocom%2Fmotan-go/lists"}