GithubHelp home page GithubHelp logo

go-moa-client's Introduction

MOA Client使用方式

  • 安装: 安装ZooKeeper (或者使用本地文件指定连接特定Server) $Zookeeper/bin/zkServer.sh start

    go get  github.com/blackbeans/go-moa-client
    
    
  • 定义服务的接口对应的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

    BenchmarkParallerMakeRpcFunc-8   	   50000	     28315 ns/op

go-moa-client's People

Contributors

blackbeans avatar hunyxv avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.