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://codercto.com/soft/d/3343.html

素数之恋

素数之恋

(美)约翰·德比希尔 / 陈为蓬 / 上海科技教育出版社 / 2008-12-01 / 34.00元

1859年8月,没什么名气的32岁数学家黎曼向柏林科学院提交了一篇论文,题为“论小于一个给定值的素数的个数”。在这篇论文的中间部分,黎曼作了一个附带的备注——一个猜测,一个假设。他向那天被召集来审查论文的数学家们抛出的这个问题,结果在随后的年代里给无数的学者产生了近乎残酷的压力。时至今日,在经历了150年的认真研究和极力探索后,这个问题仍然悬而未决。这个假设成立还是不成立? 已经越来越清楚,......一起来看看 《素数之恋》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

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

正则表达式在线测试