Documentation ¶
Index ¶
- Constants
- Variables
- func Default() map[string]ComponentLoadFunc
- func FindCallExprWithType(args []ast.Expr, exprType string) (*ast.CallExpr, int, error)
- func LoadCaseComponent(caseCallExpr *ast.CallExpr, f FlowLoader) (types.Component, error)
- func LoadComponentsWithTypes(exprs []ast.Expr, f FlowLoader, typeStrings ...string) (map[string]types.Component, []ast.Expr, error)
- func LoadDecisionComponent(effeDecisionFuncCall *ast.CallExpr, f FlowLoader) (types.Component, error)
- func LoadSimpleComponent(effeStepFuncCall *ast.CallExpr, f FlowLoader) (types.Component, error)
- func LoadWrapComponent(effeWrapFuncCall *ast.CallExpr, f FlowLoader) (types.Component, error)
- func NewComponentsFromArgs(args []ast.Expr, f FlowLoader) ([]types.Component, error)
- func ParseAndRemoveServiceComponents(exprs []ast.Expr, types ...string) (map[string]*ast.CallExpr, []ast.Expr, error)
- func RemoveExprByIndex(exprs []ast.Expr, index int) []ast.Expr
- type ComponentLoadFunc
- type FlowLoader
- type Loader
- type Option
Constants ¶
const ( // wrap helpers WrapExprType = "Wrap" BeforeExprType = "Before" SuccessExprType = "Success" // decision DecisionExprType = "Decision" CaseExprType = "Case" //others StepExprType = "Step" FailureExprType = "Failure" )
Variables ¶
var (
ErrNoExpr = errors.New("no expr in args")
)
Functions ¶
func Default ¶
func Default() map[string]ComponentLoadFunc
Loaders for components from github.com/GettEngineering/effe/types package
func FindCallExprWithType ¶
func LoadCaseComponent ¶
LoadCaseComponent converts an expression declared with effe.Case to a component with type types.CaseComponent
func LoadComponentsWithTypes ¶
func LoadComponentsWithTypes(exprs []ast.Expr, f FlowLoader, typeStrings ...string) (map[string]types.Component, []ast.Expr, error)
LoadComponentsWithTypes parses expressions in first argument and searches expressions with types in last argument. After that this method execute a method LoadComponent for each component and returns a set of components. Key is a string representation of the type.
func LoadDecisionComponent ¶
func LoadDecisionComponent(effeDecisionFuncCall *ast.CallExpr, f FlowLoader) (types.Component, error)
LoadDecisionComponent converts an expression declared with effe.Decision to a component with type types.DecisionComponent
func LoadSimpleComponent ¶
LoadSimpleComponent converts an expression declared with effe.Step to a component with type types.SimpleComponent
func LoadWrapComponent ¶
LoadWrapComponent converts an expression declared with effe.Wrap to a component with type types.WrapComponent
func NewComponentsFromArgs ¶
Types ¶
type ComponentLoadFunc ¶
Type for loaders uses in Loader.
type FlowLoader ¶
type FlowLoader interface { LoadComponent(call *ast.CallExpr) (types.Component, error) GetFuncDecl(string) (*ast.FuncDecl, bool) }
FlowLoader provides functions which use in Loader. It's a helper for easy reusing existed code
type Loader ¶
type Loader interface { // LoadFlow takes array of expressions and set of function declartions and returns an // array of components and a failure component. LoadFlow([]ast.Expr, map[string]*ast.FuncDecl) ([]types.Component, types.Component, error) // Adds new handler by type here. Register(apiExtType string, c ComponentLoadFunc) error // Returns a declaration of function by name GetFuncDecl(name string) (*ast.FuncDecl, bool) }
Loader converts flow expressions to components
type Option ¶
type Option func(l *loader)
func WithLoaders ¶
func WithLoaders(loaders map[string]ComponentLoadFunc) Option
WithLoaders is used for settings new loaders in a Loader. Default loaders are used from the method DefaultLoader
func WithPackages ¶
WithPackages is used for checking permitted packages which are used in DSL. It is necessary because you can add a custom expression type.
Example
func BuildMyBusinessFlow(){ effe.BuildFLow( effe.Step(step1), custompkg.MyStep(step2), ) } // You need custompkg to loader packages gen := generator.NewGenerator( generator.WithSetttings(settings), generator.WithLoader(loaders.NewLoader(loaders.WithPackages([]string{"effe", "custompkg"}))), generator.WithDrawer(drawer.NewDrawer()), generator.WithStrategy( strategies.NewChain(strategies.WithServiceObjectName(settings.LocalInterfaceVarname())), ), )