1 Star 0 Fork 0

Beta版厨子3.0® / go-moa-client

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

MOA Client使用方式

  • Usage

    样例参考

  • 安装: 安装ZooKeeper $Zookeeper/bin/zkServer.sh start

    go get  github.com/blackbeans/go-moa-client/client
    go get  github.com/blackbeans/go-moa/proxy
    
  • 定义服务的接口对应的struct

    • 例如接口为:
        //接口
        type IGoMoaDemo interface {
            GetDemoName(serviceUri, proto string) (DemoResult, error)
        }  
        转换为如下结构体
        type GoMoaDemo struct {
                GetDemoName func(serviceUri, proto string) (CDemoResult, error)
        }
  • 客户端启动:

       consumer := client.NewMoaConsumer("go_moa_client.toml",
           []proxy.Service{proxy.Service{
               ServiceUri: "/service/bibi/go-moa",
               Interface:   &GoMoaDemo{}},
       })
       //获取调用实例
       h := consumer.GetService("/service/bibi/go-moa").(*GoMoaDemo)
    
       for i := 0; i < 10000; i++ {
           a, err := h.GetDemoName("/service/user-profile", "redis")
    
           fmt.Printf("GetDemoName|%s|%v\n", a, err)
       }
  • 说明

    • Service为一个服务单元,对应了远程调用的服务名称、以及对应的接口

    • MoaConsumer需要对应的Moa的配置文件,toml类型,具体配置参见conf/moa_client.toml

  • Benchmark

    env:Macbook Pro 2.2 GHz Intel Core i7

    go test --bench=".*" github.com/blackbeans/go-moa-client/client -run=BenchmarkMakeRpcFunc

    BenchmarkMakeRpcFunc-8 20000 64517 ns/op

  • redis-benchmark

    • env:Macbook Pro 2.2 GHz Intel Core i7

    • go run github.com/blackbeans/go-moa-client/benchmark.go

    redis-benchmark -h host -p 13000 -n 1000000 -c 100 get '{"action":"/service/bibi/go-moa","params":{"m":"setName","args":["a"]}}'

空文件

简介

go-moa-client is an easing way to use go-moa 展开 收起
Go
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/blackbeans/go-moa-client.git
git@gitee.com:blackbeans/go-moa-client.git
blackbeans
go-moa-client
go-moa-client
master

搜索帮助