genrpc

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Description = "As default, it will read task defination from stdin, if --file was given, it would read from the file."
View Source
var Flags = []cli.Flag{
	cli.StringFlag{
		Name:  "file,f",
		Usage: "read task defination from `FILE`",
	},
}
View Source
var Usage = "auto generate rpc methods"

Functions

func Action

func Action(c *cli.Context) error

Types

type CheckDesc

type CheckDesc struct {
	Expr  string
	Error string
}

type ConverterDesc

type ConverterDesc struct {
	Source    string
	Target    string
	Converter string
}

type ConverterProc

type ConverterProc struct {
	Source    string
	Target    string
	Converter *parser.FuncType
}

type Generator

type Generator struct {
	File *parser.File

	PackageName  string
	Imports      []ImportLine
	Receiver     *parser.DeclNode
	ReceiverType parser.Type

	InterfaceType parser.Type
	Functions     map[string]parser.Type

	ServiceReceiver     *parser.DeclNode
	ServiceReceiverType string
	ServicePackage      *parser.Package

	Taskes []*Task
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator() *Generator

func (*Generator) AddImport

func (g *Generator) AddImport(name string, path string) string

func (*Generator) Bytes

func (g *Generator) Bytes() []byte

Bytes return the generated bytes

func (*Generator) Format

func (g *Generator) Format() ([]byte, error)

format returns the gofmt-ed contents of the Generator's buffer.

func (*Generator) Generate

func (g *Generator) Generate(yamlConf *YamlConfig) error

func (*Generator) PrepareFunctions

func (g *Generator) PrepareFunctions(names map[string]string)

func (*Generator) PrepareImports

func (g *Generator) PrepareImports(imports map[string]string)

func (*Generator) PrepareInterface

func (g *Generator) PrepareInterface(name string)

func (*Generator) PreparePackage

func (g *Generator) PreparePackage(dir string, files []string)

func (*Generator) PrepareParser

func (g *Generator) PrepareParser()

func (*Generator) PrepareReceiver

func (g *Generator) PrepareReceiver(name string)

func (*Generator) PrepareService

func (g *Generator) PrepareService(name string)

func (*Generator) PrepareTaskes

func (g *Generator) PrepareTaskes(taskes map[string]TaskDesc)

func (*Generator) Printf

func (g *Generator) Printf(format string, args ...interface{})

func (*Generator) Run

func (g *Generator) Run()

generate produces the function

type ImportLine

type ImportLine struct {
	Name string
	Path string
}

func (ImportLine) String

func (l ImportLine) String() string

type ParamDesc

type ParamDesc struct {
	Name string
	Expr string
	Type string
}

[]CheckDesc

type ProcDesc

type ProcDesc struct {
	Checks   []string
	Call     string
	RCall    string `yaml:"rcall"`
	Converts []string
	Error    string
	Params   []ParamDesc
	Assigns  []string
	Ignores  []int
	Returns  []string
}

type RCallDesc

type RCallDesc struct {
	Receiver string
	Func     string
	Params   []string
}

func NewRCallDsec

func NewRCallDsec(src string) *RCallDesc

type ServiceDesc

type ServiceDesc struct {
	Function string
}

type Task

type Task struct {
	Name         string
	RpcFunction  parser.Type
	ErrorWrapper parser.Type
	CheckParams  []CheckDesc
	Sequence     []*TaskProc
}

type TaskDesc

type TaskDesc struct {
	Name         string
	Sequence     []ProcDesc
	ErrorWrapper string `yaml:"error_wrapper"`
}

type TaskProc

type TaskProc struct {
	Checks  []string
	Call    parser.Type
	RCall   string
	Params  []ParamDesc
	Error   string
	Ignores []int
	Assigns []string
	Returns []string
}

type YamlConfig

type YamlConfig struct {
	Version   string
	Dir       string
	Files     []string
	Imports   map[string]string
	Output    string
	Receiver  string
	Interface string
	Generates map[string]TaskDesc
	Functions map[string]string
}

Jump to

Keyboard shortcuts

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