idl2lang

command module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 10 Imported by: 0

README

idl2lang

介绍

idl2lang工具,输入json,读取对应的模板,输出出对应的文件

使用说明

命令行查看 : idl2lang help

NAME:
   idl2lang - Plato 协议生成工具

USAGE:

  _____    _ _ ___  _
 |_   _|  | | |__ \| |
   | |  __| | |  ) | | __ _ _ __   __ _
   | | / _· | | / /| |/ _· | ·_ \ / _· |
  _| || (_| | |/ /_| | (_| | | | | (_| |
 |_____\__,_|_|____|_|\__,_|_| |_|\__, |
                                   __/ |
                                  |___/


COMMANDS:
   help, h  idl2lang helper
   code, c  生成rpc框架代码相关代码,参数[template1,template2]
   data, d  生成rpc数据层struct代码,参数[template1,template2]
   enum, e  生成rpc数据层enum代码,参数[template1,template2]
   sdk,     生成sdk版本代码模板 --proxy 模式不生成服务
   pubgo,   生成pubgo 模板代码生成

GLOBAL OPTIONS:
   --source value, -s value  读取frontend生成的json,解析代码生成信息
   --out value, -o value     设置输出目录
   --limit value, -l value   限制只生成某种服务
   --proxy, -p               是否生成proxy模式 (default: false)
   --file value, -f value    输出文件名字

命令说明

输入顺序, 先option 后 command idl2lang -s sdk

公共参数
  • s json源文件, idlname.idl.lang.json 文件
  • o 输出目录,不同命令会有不同的子文件夹创建
  • proxy 是否以proxy 模式生成
  • file 输出文件命名前缀,如果没有会使用服务名+temple名字
code command

生成rpc 框架代码,例如proxy stub 等

  • out 会输出为 一个服务一个新文件夹
  • 传入的数据结构为
名字 类型 描述
Name string 服务名字
Service *ServiceNode 解析出来的服务节点
HasStruct bool 是否有公共文件结构体
Idlname string idl 包名字用于管理公共的结构体
data&enum command

生成data数据结构相关代码,

  • out 不会创建子文件夹
名字 类型 描述
Struct *StructNode 结构体信息 data 命令时候才赋值
Enum *EnumNode 枚举信息,enum 命令时候才赋值
Idlname string idl名字

公共数据结构

ComplexNode

set dict 这种复合结构的key value 信息

名字 类型 描述
IdlType string idl中的类型,如i32
Type string 对应语言中的类型, 如int32
IsStruct bool 是否是结构体
ArgNode

方法参数结构

名字 类型 描述
IdlType string idl中的类型,如i32
Type string 对应语言中的类型, 如int32
IsStruct bool 是否是结构体
IsEnum bool 是否为枚举
DeclName string 自定义的名字
Index uint32 参数序号
Key *ComplexNode key 如果是dic 或者 set 或 seq 的key
Value *ComplexNode value 如果是dic 或者 set 或 seq 的key
FieldNode

结构体字段描述结构

名字 类型 描述
IdlType string idl中的类型,如i32
Type string 对应语言中的类型, 如int32
IsStruct bool 是否是结构体
IsEnum bool 是否为枚举
Name string 字段名字
Index uint32 字段序号
Key *ComplexNode key 如果是dic 或者 set 或 seq 的key
Value *ComplexNode value 如果是dic 或者 set 或 seq 的key
MethodNode

方法描述结构体

名字 类型 描述
Arguments []*ArgNode 参数数组
Oneway bool idl中是否被oneway修饰
RetType *ArgNode 返回值类型
Noexcept bool 是否被noexcept修饰
Name string 方法名字
Event bool 是否为事件
Index uint32 方法序号
Retry uint32 重试次数
TimeOut uint32 超时时间 单位毫秒
ServiceNode

服务节点结构体描述

名字 类型 描述
LoadType string 加载类型dynamic or static
MaxInst uint32 最大服务实例数量
Methods []*MethodNode 方法集合
Name string 服务名
Type string 服务类型single, reentrant, multiple
Uuid string 服务uuid
EnumFieldNode

枚举字段描述结构

名字 类型 描述
Name string 枚举字段名字
Value int32 枚举字段值
EnumNode

枚举相关的json结构

名字 类型 描述
Name string 枚举名字
Fields []*EnumFieldNode 枚举字段集合
StructNode

结构体描述结构

名字 类型 描述
Name string 结构体名字
Fields []*FieldNode 结构体字段集合

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