• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

go-moa-client: go-moa-client is an easing way to use go-moa

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

go-moa-client

开源软件地址:

https://gitee.com/blackbeans/go-moa-client

开源软件介绍:

MOA Client使用方式

  • Usage

    样例参考

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

    go get  github.com/blackbeans/go-moa-client/clientgo 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"]}}'


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap