rule

package
v0.0.0-...-c13ded3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RULE_TAG_NAME        = "rule_name"
	RULE_TAG_RELY_ON     = "rule_rely_on" // json format
	RULE_TAG_VERSION     = "rule_version"
	RULE_TAG_DESCRIPTION = "rule_description"
	RULE_TAG_PARAMS      = "rule_params" //json format
)
View Source
const (
	ConfigTag = "//--config--"
)
View Source
const (
	RuleTypeGo = "go"
)

Variables

View Source
var (
	ErrNotRuleName       = errors.New("unknown rule name")
	ErrDependencyFormat  = errors.New("dependency format error")
	ErrorUnknownRuleType = errors.New("unknown rule type")
)

Functions

func CleanAllRule

func CleanAllRule(stage *log.Stage)

func LoadRuleWithDir

func LoadRuleWithDir(stage *log.Stage, dir string) error

func LoadRuleWithLocal

func LoadRuleWithLocal(stage *log.Stage, path string) error

func ReLoadRuleWithDir

func ReLoadRuleWithDir(stage *log.Stage, dir string) error

func RegistryRule

func RegistryRule(stage *log.Stage, info Info)

func RegistryRuleAndStoreToLocal

func RegistryRuleAndStoreToLocal(stage *log.Stage, info Info) error

Types

type Golang

type Golang struct {
	// contains filtered or unexported fields
}

func NewGolang

func NewGolang(stage *log.Stage, content string) (*Golang, error)

func (*Golang) AddRelyOn

func (g *Golang) AddRelyOn(recipient string, dependency action.Action) error

func (*Golang) Compile

func (g *Golang) Compile() error

func (*Golang) Do

func (g *Golang) Do(ctx context.Context) error

func (*Golang) Get

func (g *Golang) Get(name string) (*action.Value, error)

func (*Golang) Info

func (g *Golang) Info() Info

func (*Golang) Set

func (g *Golang) Set(recipient string, value *action.Value) error

func (*Golang) SetError

func (g *Golang) SetError(i interface{})

type GolangAction

type GolangAction struct {
	// contains filtered or unexported fields
}

func (*GolangAction) Description

func (g *GolangAction) Description() string

func (*GolangAction) Do

func (g *GolangAction) Do(params ...*action.Value) (map[string]*action.Value, error)

func (*GolangAction) Func

func (g *GolangAction) Func() func(params ...interface{}) (map[string]*action.Value, error)

func (*GolangAction) Name

func (g *GolangAction) Name() string

func (*GolangAction) Version

func (g *GolangAction) Version() float32

type Info

type Info interface {
	Name() string
	Description() string
	Version() float32
	OriginalContent() string
	Author() string
	RuleType() RuleType
	GetRelyOn() map[string]string        // map[recipient]dependency
	GetParams() map[string]*action.Value // the dynamic parameters and default values that the rule can accept are recorded here
	Key() string
}

type Rule

type Rule interface {
	Info() Info
	Set(recipient string, value *action.Value) error
	AddRelyOn(recipient string, dependency action.Action) error
	Get(name string) (*action.Value, error) // Generally, you can get it after the rule is executed.
	Do(ctx context.Context) error
	Compile() error // be careful not to recompile
}

func GetRule

func GetRule(stage *log.Stage, name string, version float32) (rule Rule, exist bool, err error)

GetRule returns the latest rule when the incoming version is -1

type RuleConfig

type RuleConfig map[string]interface{}

type RuleType

type RuleType string

Jump to

Keyboard shortcuts

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