All Projects → weibocom → Motan Go

weibocom / Motan Go

Licence: other
The golang implementation of Motan

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Motan Go

meshRPC
Automatic Service Mesh and RPC generation for Go micro services, it's a humble alternative to gRPC with Istio.
Stars: ✭ 69 (-83.41%)
Mutual labels:  rpc-framework, service-mesh
Apioak
Full Lifecycle Management API Gateway.
Stars: ✭ 335 (-19.47%)
Mutual labels:  service-mesh
Skywalking
APM, Application Performance Monitoring System
Stars: ✭ 18,341 (+4308.89%)
Mutual labels:  service-mesh
Slacker
Transparent, non-incursive RPC by clojure and for clojure
Stars: ✭ 316 (-24.04%)
Mutual labels:  rpc-framework
Juno
Juno 译名朱诺。这个名字来源于古罗马神话中的众神之母。它是斗鱼的微服务管理系统, 如同众神之母一样守护着所有微服务的系统。
Stars: ✭ 285 (-31.49%)
Mutual labels:  service-mesh
Admiral
Admiral provides automatic configuration generation, syncing and service discovery for multicluster Istio service mesh
Stars: ✭ 323 (-22.36%)
Mutual labels:  service-mesh
Mosn
The Cloud-Native Network Proxy Platform.
Stars: ✭ 3,451 (+729.57%)
Mutual labels:  service-mesh
Istio
Istio官方文档中文版
Stars: ✭ 389 (-6.49%)
Mutual labels:  service-mesh
Easyrpc
EasyRPC是一个远程过程调用(Remote Procedure Call,简称RPC)的最小实现。它使用极少的类、方法演示了RPC的实现原理,是一个学习RPC工作原理的良好示例。
Stars: ✭ 329 (-20.91%)
Mutual labels:  rpc-framework
Light 4j
A fast, lightweight and more productive microservices framework
Stars: ✭ 3,303 (+693.99%)
Mutual labels:  service-mesh
Awesome Servicemesh
Awesome service mesh - https://www.servicemesher.com/awesome-servicemesh/
Stars: ✭ 302 (-27.4%)
Mutual labels:  service-mesh
Skyapm Php Sdk
The PHP instrument agent for Apache SkyWalking
Stars: ✭ 292 (-29.81%)
Mutual labels:  service-mesh
Sofa Rpc
SOFARPC is a high-performance, high-extensibility, production-level Java RPC framework.
Stars: ✭ 3,479 (+736.3%)
Mutual labels:  rpc-framework
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+715.38%)
Mutual labels:  rpc-framework
Rpc Websockets
JSON-RPC 2.0 implementation over WebSockets for Node.js and JavaScript/TypeScript
Stars: ✭ 344 (-17.31%)
Mutual labels:  rpc-framework
Dew
微服务一站式解决方案,提供:架构指南、容器优先/兼容Spring Cloud与Service Mesh的框架、最佳实践及Devops标准化流程。
Stars: ✭ 285 (-31.49%)
Mutual labels:  service-mesh
Kubernetes Workshop
⚙️ A Gentle introduction to Kubernetes with more than just the basics. 🌟 Give it a star if you like it.
Stars: ✭ 3,122 (+650.48%)
Mutual labels:  service-mesh
Vertx Zero
Zero Framework:http://www.vertxup.cn
Stars: ✭ 320 (-23.08%)
Mutual labels:  service-mesh
Meetup Slides
Slides archive of Service Mesh meetups - https://www.servicemesher.com/tags/meetup
Stars: ✭ 403 (-3.12%)
Mutual labels:  service-mesh
Istio Handbook
Istio Handbook - Istio Service Mesh Advanced Practical(Istio 服务网格进阶实战) - https://jimmysong.io/istio-handbook
Stars: ✭ 374 (-10.1%)
Mutual labels:  service-mesh

Motan-go

License Build Status codecov GoDoc Go Report Card

Overview

Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.

This project is the golang Motan implementation. Provides golang motan server, motan client and motan agent. motan agent is designed to support bio-proxy for any other language such as PHP, Python by motan2 protocol.

Features

  • Interactive with mulit language through motan2 protocol,such as Java, PHP.
  • Provides cluster support and integrate with popular service discovery services like Consul or Zookeeper.
  • Supports advanced scheduling features like weighted load-balance, scheduling cross IDCs, etc.
  • Optimization for high load scenarios, provides high availability in production environment.
  • Supports both synchronous and asynchronous calls.

Quick Start

Installation

go get -u -v github.com/weibocom/motan-go

The 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. the demo case is in the main/ directory

Motan server

  1. Create serverdemo.yaml to config service
#config of registries
motan-registry:
  direct-registry: # registry id 
    protocol: direct   # registry type

#conf of services
motan-service:
  mytest-motan2:
    path: com.weibo.motan.demo.service.MotanDemoService # e.g. service name for register
    group: motan-demo-rpc
    protocol: motan2
    registry: direct-registry
    serialization: simple
    ref : "main.MotanDemoService"
    export: "motan2:8100"
  1. Write an implementation, create and start RPC Server.
package main

import (
	"fmt"
	"time"

	motan "github.com/weibocom/motan-go"
)

func main() {
	runServerDemo()
}

func runServerDemo() {
	mscontext := motan.GetMotanServerContext("serverdemo.yaml") //get config by filename
	mscontext.RegisterService(&MotanDemoService{}, "") // registry implement
	mscontext.Start(nil) // start server
	time.Sleep(time.Second * 50000000)
}

// service implement
type MotanDemoService struct{}

func (m *MotanDemoService) Hello(name string) string {
	fmt.Printf("MotanDemoService hello:%s\n", name)
	return "hello " + name
}

Motan client

  1. Create clientdemo.yaml to config service for subscribe
#config of registries
motan-registry:
  direct-registry: # registry id 
    protocol: direct   # registry type. 
    host: 127.0.0.1 
    port: 9981 

#conf of refers
motan-refer:
  mytest-motan2:
    path: com.weibo.motan.demo.service.MotanDemoService # e.g. service name for subscribe
    group: motan-demo-rpc # group name
    protocol: motan2 # rpc protocol
    registry: direct-registry
    requestTimeout: 1000
    serialization: simple
    haStrategy: failover
    loadbalance: roundrobin
  1. Start call
package main

import (
	"fmt"

	motan "github.com/weibocom/motan-go"
	motancore "github.com/weibocom/motan-go/core"
)

func main() {
	runClientDemo()
}

func runClientDemo() {
	mccontext := motan.GetClientContext("clientdemo.yaml")
	mccontext.Start(nil)
	mclient := mccontext.GetClient("mytest-motan2")

	var reply string
	err := mclient.Call("hello", []interface{}{"Ray"}, &reply)  // sync call
	if err != nil {
		fmt.Printf("motan call fail! err:%v\n", err)
	} else {
		fmt.Printf("motan call success! reply:%s\n", reply)
	}

	// async call
	result := mclient.Go("hello", []interface{}{"Ray"}, &reply, make(chan *motancore.AsyncResult, 1))
	res := <-result.Done
	if res.Error != nil {
		fmt.Printf("motan async call fail! err:%v\n", res.Error)
	} else {
		fmt.Printf("motan async call success! reply:%+v\n", reply)
	}
}

Use agent.

agent is not necessary for golang. it designed for interpreted languages such as PHP to support service governance

  1. Create clientdemo.yaml to config service for subscribe or register
#config fo agent
motan-agent:
  port: 9981 # agent serve port. 
  mport: 8002 # agent manage port 

#config of registries
motan-registry:
  direct-registry: # registry id 
    protocol: direct   # registry type. will get instance from extFactory.
    host: 127.0.0.1 # direct server ip.
    port: 8100 #direct server port

#conf of refers
motan-refer:
  mytest-motan2:
    path: com.weibo.motan.demo.service.MotanDemoService # e.g. service name for subscribe
    group: motan-demo-rpc
    protocol: motan2
    registry: direct-registry
    serialization: simple
  1. Start Agent
package main

import motan "github.com/weibocom/motan-go"

func main() {
	runAgentDemo()
}

func runAgentDemo() {
	agent := motan.NewAgent(nil)
	agent.ConfigFile = "./agentdemo.yaml"
	agent.StartMotanAgent()
}

Documents

Contributors

License

Motan is released under the Apache License 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].