strategies

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFailureReturnStmt

func BuildFailureReturnStmt(output *ast.FieldList, vars map[string]*ast.Ident, defaultErrMsg string, typesInfo *types.Info) (*ast.ReturnStmt, bool)

func BuildMultiComponentName

func BuildMultiComponentName(calls []ComponentCall) *ast.Ident

func BuildReturnStmt

func BuildReturnStmt(output *ast.FieldList, vars map[string]*ast.Ident, typesInfo *types.Info) *ast.ReturnStmt

func Default

func Default() map[string]Generator

Types

type BlockContext

type BlockContext struct {
	Input   *ast.FieldList
	Output  *ast.FieldList
	Vars    map[string]*ast.Ident
	Builder VarBuilder
}

func NewBlockContext

func NewBlockContext() *BlockContext

func (*BlockContext) AddInput

func (b *BlockContext) AddInput(t ast.Expr) *ast.Field

func (*BlockContext) BuildInputVars

func (b *BlockContext) BuildInputVars(input *ast.FieldList) []*ast.Field

func (*BlockContext) BuildOutputVars

func (b *BlockContext) BuildOutputVars(output *ast.FieldList) ([]*ast.Field, bool)

func (*BlockContext) CalculateInput

func (b *BlockContext) CalculateInput(calls []ComponentCall)

func (*BlockContext) CalculateOutput

func (b *BlockContext) CalculateOutput(calls []ComponentCall)

func (BlockContext) FindInputByType

func (b BlockContext) FindInputByType(t ast.Expr) *ast.Field

func (*BlockContext) OutputList

func (b *BlockContext) OutputList() []*ast.Field

type Chain

type Chain interface {
	BuildFlow([]types.Component, types.Component, *goTypes.Info) (ast.Expr, []string, error)
	Register(string, Generator) error
}

func NewChain

func NewChain(opts ...Option) Chain

type ComponentCall

type ComponentCall interface {
	Fn() ast.Expr
	Input() *ast.FieldList
	Output() *ast.FieldList
	Name() *ast.Ident
}

func BuildMultiComponentCall

func BuildMultiComponentCall(f FlowGen, calls []ComponentCall, failureCall ComponentCall) ComponentCall

func GenCaseComponentCall

func GenCaseComponentCall(f FlowGen, cComponent types.Component) (ComponentCall, error)

func GenComponentCalls

func GenComponentCalls(f FlowGen, components ...types.Component) ([]ComponentCall, error)

func GenDecisionComponentCall

func GenDecisionComponentCall(f FlowGen, dComponent types.Component) (ComponentCall, error)

func GenSimpleComponentCall

func GenSimpleComponentCall(f FlowGen, sComponent types.Component) (ComponentCall, error)

func GenWrapComponentCall

func GenWrapComponentCall(f FlowGen, wComponent types.Component) (ComponentCall, error)

type ComponentStmt

type ComponentStmt interface {
	Stmt() ast.Stmt
	InputFields() []*ast.Field
	OutputFields() []*ast.Field
	ErrStmt() *ast.BlockStmt
	Name() string
}

type FlowGen

type FlowGen interface {
	AddImport(string)
	BuildComponentStmt(ctx *BlockContext, cCall, failureCall ComponentCall) ComponentStmt
	ApplyPlugins(ctx *BlockContext, componentStmt ComponentStmt) *ast.BlockStmt
	ServiceName() string
	VarBuilder() VarBuilder
	GenComponentCall(types.Component) (ComponentCall, error)
	TypesInfo() *goTypes.Info
}

type Generator

type Generator func(FlowGen, types.Component) (ComponentCall, error)

type Option

type Option func(c *chain)

func Use

func Use(p plugin.Plugin) Option

func WithServiceObjectName

func WithServiceObjectName(newServiceObjectName string) Option

type VarBuilder

type VarBuilder func(t ast.Expr) *ast.Ident

Jump to

Keyboard shortcuts

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