开源软件名称: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) } 说明 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 redis-benchmark -h host -p 13000 -n 1000000 -c 100 get '{"action":"/service/bibi/go-moa","params":{"m":"setName","args":["a"]}}' |
请发表评论