GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - blackbeans/go-moa: go-moa is a simple rpc framework for golang.

BranchesTags
Open more actions menu

Latest commit

 

History

220 Commits
220 Commits

Folders and files

NameName
Last commit message
Last commit date
conf
conf
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
application.go
application.go
 
 
application_test.go
application_test.go
 
 
code_enum.go
code_enum.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
moa_codec.go
moa_codec.go
 
 
moa_codec_test.go
moa_codec_test.go
 
 
option.go
option.go
 
 
proxy.go
proxy.go
 
 
proxy_test.go
proxy_test.go
 
 
registry.go
registry.go
 
 
registry_file.go
registry_file.go
 
 
registry_file_test.go
registry_file_test.go
 
 
registry_zk.go
registry_zk.go
 
 
registry_zk_test.go
registry_zk_test.go
 
 
stat.go
stat.go
 
 
zk.go
zk.go
 
 

Repository files navigation

MOA Server

简介

* 支持zk做集群管理
* 支持本地配置配置集群
* 基于[turbo](https://github.com/blackbeans/turbo)
* 使用json序列化协议作为传用户协议传输
* 基于GroupId划分同服务下的服务,做到环境隔离

使用样例

样例参考

MOA协议简介

  • 基于turbo的二进制协议(https://github.com/blackbeans/turbo/packet)

  • {"action":"/service/bibi/go-moa","params":{"m":"setName","args":["a"]}}

    action:理解为服务名称(service-uri)

    m:需要调用该服务的方法名称(已经做了go和java关于方法名首字母大写兼容)

    args:m方法的调用参数序列。

安装:

  • 安装ZooKeeper (不需要集群可以不安装) $Zookeeper/bin/zkServer.sh start
```
    go get  github.com/blackbeans/go-moa/core
  
```
  • 定义服务的接口对应
  • 例如接口为:

        //接口
        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
        }
     ```
    
  • 约定: 为了给客户端友好的返回错误信息,go-moa的服务接口最后一个返回必须为error类型。并且为了满足Java单一返回结果所以返回参数最多2个。

  • 服务端启动启动:

    ```goalng
    
       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.DestroyApplication()
       }
    
    
    
  • 说明

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

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

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

Moa状态接口

  • MOAHOME

    URL :

        http://host:${moaport+1000}/debug/moa

    返回 :

      ```text
      /debug/moa/
    
      Types of moaprofiles available:
      moa
      index	
      MOA首页
      
      stat	
      MOA系统状态指标
      
      list.clients	
      MOA当前所有连接
      
      list.services	
      MOA发布的服务列表
      
      list.methods	
      MOA来源调用统计信息
      ```
    
  • 查询MOA状态信息

    URL :

        http://host:${moaport+1000}/debug/moa/stat

    返回 :

      ```json
      {
          recv: 0, //接收请求数
          proc: 0, //处理请求数
          error: 0, //处理失败数量
          timeout: 0, //超时数量
          invoke_gos: 0, //方法执行的gopool 
          conns: 0, //客户端连接数
          total_gos: 12 //总goroutine数量
       }
      ```
    
  • 查询MOA发布的服务列表

    URL :

        http://host:${moaport+1000}/debug/moa/list/services

    返回 :

        [
          "/service/go-moa"
        ]
    
  • 查询服务方法调用统计情况

    URL :

        http://host:${moaport+1000}/debug/moa/list/methods?service=/service/go-moa

    返回 :

        [
            {
              client: "192.168.50.88:63072",
              service_name: "/service/go-moa",
              methods: [
                  {
                    name: "SetName",
                    count: 58939 //总调用次数
                  }
              ]
          }
        ]      

About

go-moa is a simple rpc framework for golang.

Resources

Readme
Activity

Stars

24 stars

Watchers

6 watching

Forks

5 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.