RPC 框架 Go-MOA

码农软件 · 软件分类 · RPC/XMLRPC项目 · 2019-04-11 12:42:44

软件介绍

Go-MOA 是使用redis get请求协议的RPC 框架。

MOA Server使用方式

  • 安装:

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

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

        //接口
        type DemoResult struct {
            Hosts []string `json:"hosts"`
            Uri   string   `json:"uri"`
        }
    
        type IGoMoaDemo interface {
            GetDemoName(serviceUri, proto string) (DemoResult, error)
        }
        //服务实现
        type GoMoaDemo struct {
        }
    
        func (self GoMoaDemo) GetDemoName(serviceUri, proto string) (DemoResult, error)      {
            return DemoResult{[]string{"fuck gfw"}, serviceUri}, nil
        }
    • 例如接口为:

  • 服务端启动启动:

        func main(){
            app := core.NewApplcation("./conf/cluster_test.toml", 
            func() []proxy.Service {
                return []proxy.Service{
                    proxy.Service{
                        ServiceUri: "/service/bibi/go-moa",
                        Instance:   GoMoaDemo{},
                        Interface:  (*IGoMoaDemo)(nil)}}
            })
    
            //设置启动项
            ch := make(chan os.Signal, 1)
            signal.Notify(ch, os.Kill)
            //kill掉的server
            <-ch
            app.DestoryApplication()
        }
  • 说明

    • Service为一个服务单元,对应了本服务对外的服务名称、以及对应的接口

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

  • 发布服务成功可以使用客户端进行测试,具体客户端的使用请参考

*** Benchmark

env:Macbook Pro 2.2 GHz Intel Core i7

go test --bench=".*" github.com/blackbeans/go-moa/core -run=BenchmarkApplication

BenchmarkApplication-8     20000         64517 ns/op

本文地址:https://www.codercto.com/soft/d/3343.html

精益数据分析

精益数据分析

[加] 阿利斯泰尔·克罗尔、[加] 本杰明·尤科维奇 / 韩知白、王鹤达 / 人民邮电出版社 / 2014-12 / 79.00元

本书展示了如何验证自己的设想、找到真正的客户、打造能赚钱的产品,以及提升企业知名度。30多个案例分析,全球100多位知名企业家的真知灼见,为你呈现来之不易、经过实践检验的创业心得和宝贵经验,值得每位创业家和企业家一读。 深入理解精益创业、数据分析基础,和数据驱动的思维模式 如何将六个典型的商业模式应用到各种规模的新企业 找到你的第一关键指标 确定底线,找到出发点 在大......一起来看看 《精益数据分析》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具