sysdes

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeBffAnnotationType      = "type"
	NameBffAnnotationType      = "name"
	LoginBffAnnotationType     = "login"
	PageBffAnnotationType      = "page"
	URIBffAnnotationType       = "uri"
	DesBffAnnotationType       = "describe"
	InterfaceBffAnnotationType = "interface"
)
View Source
const (
	TypeServiceAnnotationType = "type"
	PathServiceAnnotationType = "path"
	DesServiceAnnotationType  = "des"
)
View Source
const (
	SystemNameSubffix = "-system"
	ProtocolName      = "protocol"
	GoHostPreffix     = "git.gmtshenzhen.com/yaodao"
)

Variables

This section is empty.

Functions

func SkipImpls

func SkipImpls(fn func(_ string) bool)

func TargetImpls

func TargetImpls(fn func(_ string) bool)

Types

type AstTree

type AstTree interface {
	Parse() error
	ParseAnnotation(doc *ast.CommentGroup) error
	FillCrossStructs() error
}

type BaseAstTree

type BaseAstTree struct{}

func NewBaseAstTree

func NewBaseAstTree() *BaseAstTree

func (*BaseAstTree) FillCrossStructs

func (base *BaseAstTree) FillCrossStructs() error

func (*BaseAstTree) Parse

func (base *BaseAstTree) Parse() error

func (*BaseAstTree) ParseAnnotation

func (base *BaseAstTree) ParseAnnotation(doc *ast.CommentGroup) error

type BffAnnotationType

type BffAnnotationType = string

type BffImpl

type BffImpl struct {
	Sys      *SystemDes `json:",omitempty" yaml:"-"`
	AstTree  *BffTree   `json:"-" yaml:"-"`
	FileNode types.FileNode
}

func NewBffImpl

func NewBffImpl(fileNode types.FileNode, sysDes *SystemDes) (*BffImpl, error)

type BffInterfaceAnnotation

type BffInterfaceAnnotation struct {
	Typ   string `validate:"required,nx_contains=b.i-bff.interface"`
	Zh    string `validate:"required"`
	Login string `validate:"required"`
	URI   string
	Des   string
	Page  []string
}

type BffInterfaceTree

type BffInterfaceTree struct {
	FuncName   string `json:"-" yaml:"-"`
	FileNode   types.FileNode
	Annotation *BffInterfaceAnnotation `json:"-" yaml:"-"`
}

func (*BffInterfaceTree) FillCrossStructs

func (b *BffInterfaceTree) FillCrossStructs() error

func (*BffInterfaceTree) Parse

func (b *BffInterfaceTree) Parse() error

func (*BffInterfaceTree) ParseAnnotation

func (b *BffInterfaceTree) ParseAnnotation(docs *ast.CommentGroup) error

type BffItem

type BffItem struct {
	DirNode types.DirNode `json:",omitempty" yaml:"-"`
	Impls   []*BffImpl    `json:",omitempty" yaml:"interfaces"`
	Sys     *SystemDes    `json:",omitempty" yaml:"-"`
}

func NewBffItem

func NewBffItem(dirNode types.DirNode, sys *SystemDes) (*BffItem, error)

func (BffItem) ImplIter

func (bffItem BffItem) ImplIter(iterFn func(impl *BffImpl) bool)

func (BffItem) MatchImpl

func (bffItem BffItem) MatchImpl(fileNode types.FileNode) *BffImpl

func (BffItem) MatchImplByName

func (bffItem BffItem) MatchImplByName(implName string) *BffImpl

type BffRequestAnnotation

type BffRequestAnnotation struct {
	Typ       string `validate:"required,nx_contains=b.i.rt-bff.interface.request"`
	Interface string `validate:"required"`
}

type BffRequestTree

type BffRequestTree struct {
	Name       string
	FileNode   types.FileNode
	Annotation *BffRequestAnnotation
	TopNode    *xast.TopNode
}

func (*BffRequestTree) FillCrossStructs

func (b *BffRequestTree) FillCrossStructs() error

TODO Opz walk performance

func (*BffRequestTree) Parse

func (b *BffRequestTree) Parse() error

func (*BffRequestTree) ParseAnnotation

func (b *BffRequestTree) ParseAnnotation(docs *ast.CommentGroup) error

type BffResponseAnnotation

type BffResponseAnnotation struct {
	Typ       string `validate:"required,nx_contains=b.i.re-bff.interface.response"`
	Interface string `validate:"required"`
}

type BffResponseTree

type BffResponseTree struct {
	Name       string
	FileNode   types.FileNode
	Annotation *BffResponseAnnotation
	TopNode    *xast.TopNode
}

func (*BffResponseTree) FillCrossStructs

func (b *BffResponseTree) FillCrossStructs() error

func (*BffResponseTree) Parse

func (b *BffResponseTree) Parse() error

func (*BffResponseTree) ParseAnnotation

func (b *BffResponseTree) ParseAnnotation(docs *ast.CommentGroup) error

type BffTree

type BffTree struct {
	Interface AstTree
	Request   AstTree
	Response  AstTree
	// contains filtered or unexported fields
}

func NewBffTree

func NewBffTree(fileNode types.FileNode) (*BffTree, error)

func ParseBffInterfaceRequestAstTree

func ParseBffInterfaceRequestAstTree(fileNode types.FileNode) (*BffTree, error)

type Bffs

type Bffs struct {
	DirNode  types.DirNode `json:",omitempty" yaml:"-"`
	BffItems []*BffItem    `json:",omitempty" yaml:"names"`
	Sys      *SystemDes    `json:",omitempty" yaml:"-"`
}

func NewBffs

func NewBffs(sys *SystemDes, bffName ...string) (*Bffs, error)

func (Bffs) BffIter

func (bff Bffs) BffIter(iterFn func(item *BffItem) bool)

func (Bffs) ImplIter

func (bff Bffs) ImplIter(iterFn func(*BffItem, *BffImpl) bool)

func (Bffs) MatchBff

func (bff Bffs) MatchBff(fileNode types.FileNode) *BffItem

func (Bffs) MatchBffByName

func (bff Bffs) MatchBffByName(bffName string) *BffItem

func (Bffs) MatchBffImplByName

func (bff Bffs) MatchBffImplByName(bffName, implName string) *BffImpl

func (Bffs) MatchBffImplByPath

func (bff Bffs) MatchBffImplByPath(fileNode types.FileNode) *BffImpl

eg: MatchBffImplByPath("/xxx/user_system/bff/admin/impls/login.go"

type DepsEnv

type DepsEnv struct {
	ProjectRoot string
	GoRoot      string
	GoPath      string
	Protoc      string
	ProtocGenGo string
	Git         string
}

type ExtendTree

type ExtendTree struct {
	*xast.TopNode
}

func NewExtendTree

func NewExtendTree(tree *xast.TopNode) *ExtendTree

func (*ExtendTree) FlatNestedNodes added in v0.1.1

func (base *ExtendTree) FlatNestedNodes() *xast.TopNode

func (*ExtendTree) ReplaceExtraNode

func (topNode *ExtendTree) ReplaceExtraNode(sourceTree *xast.TopNode, fullName ...string) (count int)

Note: topNode share memory with sourcetree

type MakeFileParam

type MakeFileParam struct {
	SystemName   string
	BffNames     []string
	ServiceNames []string
}

type ServiceAnnotationType

type ServiceAnnotationType = string

type ServiceInterfaceAnnotation

type ServiceInterfaceAnnotation struct {
	Typ  string //`validate:"required,eq=b.i"`
	Path string //`validate:"required"`
}

type ServiceInterfaceTree

type ServiceInterfaceTree struct {
	FuncName string `json:"-" yaml:"-"`
	*BaseAstTree
}

func NewServiceInterfaceTree

func NewServiceInterfaceTree(funcName string) *ServiceInterfaceTree

type ServiceRequestAnnotation

type ServiceRequestAnnotation struct {
	Typ       string
	Interface string
}

type ServiceRequestTree

type ServiceRequestTree struct {
	VarName string
	*BaseAstTree
}

func NewServiceRequestTree

func NewServiceRequestTree(varName string) *ServiceRequestTree

type ServiceResponseAnnotation

type ServiceResponseAnnotation struct {
	Typ       string
	Interface string
}

type ServiceResponseTree

type ServiceResponseTree struct {
	VarName string
	*BaseAstTree
}

func NewServiceResponseTree

func NewServiceResponseTree(varName string) *ServiceResponseTree

type ServiceTree

type ServiceTree struct {
	Interface AstTree
	Request   AstTree
	Response  AstTree
	// contains filtered or unexported fields
}

type SystemDes

type SystemDes struct {
	Name       string `yaml:"name"` // "foo-system"
	ShortName  string
	Author     string `yaml:"author"`
	GoModel    string `yaml:"gomod"`
	CreateTime string `yaml:"create_time"`
	UpdateTime string `yaml:"update_time"`
	Bffs       *Bffs  `yaml:"bff,omitempty"`
	// Services   Services `yaml:"services,omitempty"`
	DirNode types.DirNode `json:",omitempty" yaml:"-"`
}

func NewSystemDes

func NewSystemDes(dirNode interface{}, bffName ...string) (*SystemDes, error)

Jump to

Keyboard shortcuts

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