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

Unity 3D脚本编程

Unity 3D脚本编程

陈嘉栋 / 电子工业出版社 / 2016-9-1 / 79

《Unity 3D脚本编程——使用C#语言开发跨平台游戏》以Unity 3D 的跨平台基础Mono,以及其游戏脚本语言C#为基础进行讲解。全面系统地剖析了Unity 3D 的跨平台原理以及游戏脚本开发的特点。 第1 章主要介绍了Unity 3D 引擎的历史以及编辑器的基本知识;第2 章主要介绍了Mono,以及Unity3D 利用Mono 实现跨平台的原理,并且分析了C#语言为什么更适合Uni......一起来看看 《Unity 3D脚本编程》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

随机密码生成器
随机密码生成器

多种字符组合密码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具