rcproxy

command module
v0.0.0-...-7d7780a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2022 License: MulanPSL-2.0 Imports: 10 Imported by: 0

README

rc 调用协议

  • REQUEST
POST /runner/{shell-name}
{
  "id": "",     //  本次调用的唯一请求id
  "object": "", //  被调用的对象的名字
  "func": "",   //  被调用的对象的函数名称
  "args": []    //  调用参数
}

  • REPONSE
{
  "id": "",     //  本次调用的唯一请求id
  "object": "", //  被调用的对象的名字
  "func": "",   //  被调用的对象的函数名称
  "result": {}  //  返回的对象
  "error": {
   "id": 123,     // 错误码
   "message": ""  // 错误描述
  },
}

Shell 定义 Schema

Schema
// ArgFlag 为参数的选项
type ArgFlag uint32

const (
Required ArgFlag = 0x01 // 必须参数
)

// Version 为一个整数版本
type Version uint32

const (
InvalidVersion Version = 0xFFFFFFFF //	无效版本号
)

// Arg 描述了一个参数对象
type Arg struct {
Name  string   `json:"name"` // 参数的名字
Type  string   `json:"type"` // 参数的类型
Flags uint32   `json:"flags,omitempty"` //	ArgFlag 的组合
}

// Func 描述了一个可调用函数
type Func struct {
Name  string   `json:"name"`  // 函数的名字
Since Version  `json:"since"` // 从什么版本开始支持
Args  []*Arg   `json:"args,omitempty"` // 参数表
}

// Object 描述了一个可调用对象
type Object struct {
Name  string   `json:"name"`    //	可调用对象的唯一名字
Since Version  `json:"version"` //	从什么版本开始支持
Funcs []*Func  `json:"funcs"` //	所有支持的可调用函数
}

// ShellrDescription 定义了一个手机侧的对象,这里记录了 Shell 的所有的信息
type Shellr struct {
Addr      string        `json:"addr"` //   一个 Shellr 对象的唯一地址
Name      string        `json:"name"` //	一个 Shellr 的名字
Versions  [2]Version    `json:"versions"`         //	Shellr 支持的版本号范围
Detial    string        `json:"detial,omitempty"` //	一个 Shellr 的详细描述
Objects   []*Object     `json:"objects"` //	所有的可调用对象
}
样例
---
name: ""
desc: ""
objects:
  - name: 
      objc: "adder"
      java: "com.baidu.adder"
      python: "add"
    versions: [ 12,14 ]
    funcs:
      - name:
          objc: "add:with"
          java: "add"
          python: "add"
        args:
          - type: "number"
            flags: [ "required" ]
          - type: "number"
            flags: [ "required" ]
      - name: 
          objc: "sub:with"
          java: "sub"
          python: "sub"
        args:
          - type: "number"
            flags: [ "required" ]
          - type: "number"
            flags: [ "required" ]

  - name: "multer"
    funcs:
      - name: "mult"
        args:
          - name: "first"
            type: "int32_t"
            flags: [ "required" ]
          - name: "second"
            type: "int32_t"
            flags: [ "required" ]
      - name: "div"
        since: 12
        args:
          - name: "first"
            type: "int32_t"
            flags: [ "required" ]
          - name: "second"
            type: "int32_t"
            flags: [ "required" ]

支持的数据类型:

  • int 系列
  • string
  • bool
  • double
  • list
  • map

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL