Documentation ¶
Index ¶
- Constants
- func ConvertValueType(value interface{}, valueType ValueType) (Value interface{}, err error)
- func InfixToRPN(parts []string) ([]string, error)
- func Operation(left Value, operator Operator, right Value) (result bool, err error)
- func RegisterAction(name string, actionStruct ActionInterface)
- func RegisterFunc(name string, function Func)
- func RegisterOperation(name Operator, op OperationFunc)
- type ActionInterface
- type ActionType
- type Assignment
- type BreakMode
- type Compare
- type Context
- type DslGetter
- type DslGetterInterface
- type ElementType
- type Flow
- type FlowNodeType
- type Func
- type Gisk
- func (gisk *Gisk) GetVariates() map[string]interface{}
- func (gisk *Gisk) Parse(elementType ElementType, key string, version string) error
- func (gisk *Gisk) SetDslFormat(format string) *Gisk
- func (gisk *Gisk) SetDslGetter(getter DslGetterInterface) *Gisk
- func (gisk *Gisk) Unmarshal(data []byte, v any) error
- type Input
- type NodeInterface
- type OperationFunc
- type Operator
- type RawMessage
- type Rule
- type Ruleset
- type Value
- type ValueInterface
- type ValueType
- type Variate
Constants ¶
View Source
const ( HitBreak = "hit_break" //规则命中中断后续规则 MissBreak = "miss_break" //规则未命中中断后续规则 )
View Source
const ( JSON = "json" YAML = "yaml" )
View Source
const FlowStartNodeKey = "start"
Variables ¶
This section is empty.
Functions ¶
func ConvertValueType ¶
ConvertValueType 转换值数据类型
func RegisterAction ¶
func RegisterAction(name string, actionStruct ActionInterface)
func RegisterFunc ¶
func RegisterOperation ¶
func RegisterOperation(name Operator, op OperationFunc)
Types ¶
type ActionInterface ¶
type ActionType ¶
type ActionType struct {
ActionType string `json:"action_type" yaml:"action_type"`
}
type Assignment ¶
type Assignment struct { ActionType ActionType Variate string `json:"variate" yaml:"variate"` Value string `json:"value" yaml:"value"` }
func (*Assignment) Parse ¶
func (a *Assignment) Parse(gisk *Gisk) error
type Compare ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) GetVariates ¶
func (*Context) SetVariate ¶
type DslGetter ¶
type DslGetter struct { Getter DslGetterInterface Dsl sync.Map }
type DslGetterInterface ¶
type DslGetterInterface interface {
GetDsl(elementType ElementType, key string, version string) (string, error)
}
type ElementType ¶
type ElementType string
ElementType 元素类型
const ( VARIATE ElementType = "variate" //变量 INPUT ElementType = "input" //输入值 FUNC ElementType = "func" //函数 RULE ElementType = "rule" //规则 RULESET ElementType = "ruleset" //规则集 FLOW ElementType = "flow" //决策流 )
type Flow ¶
type Flow struct { Key string `json:"key" yaml:"key"` //唯一标识 Name string `json:"name" yaml:"name"` //名称 Desc string `json:"desc" yaml:"desc"` //描述 Version string `yaml:"version" json:"version"` //版本 Nodes []RawMessage `json:"nodes" yaml:"nodes"` //节点 // contains filtered or unexported fields }
type FlowNodeType ¶
type FlowNodeType string
FlowNodeType 流程节点类型
const ( GeneralFlowNode FlowNodeType = "general_flow_node" BranchFlowNode FlowNodeType = "branch_flow_node" ActionFlowNode FlowNodeType = "action_flow_node" )
type Gisk ¶
type Gisk struct { DslFormat string //dsl解析格式:json 或 yaml Input map[string]interface{} //输入值 Context *Context //上下文 DslGetter *DslGetter //dsl获取器 }
func (*Gisk) GetVariates ¶
GetVariates 获取所有赋值变量
func (*Gisk) Parse ¶
func (gisk *Gisk) Parse(elementType ElementType, key string, version string) error
func (*Gisk) SetDslFormat ¶
SetDslFormat 设置dsl格式
func (*Gisk) SetDslGetter ¶
func (gisk *Gisk) SetDslGetter(getter DslGetterInterface) *Gisk
SetDslGetter 设置dsl获取器
type NodeInterface ¶
type NodeInterface interface {
Parse(gisk *Gisk, flow *Flow) ([]NodeInterface, error)
}
type OperationFunc ¶
type RawMessage ¶
type RawMessage []byte
func (RawMessage) MarshalJSON ¶
func (m RawMessage) MarshalJSON() ([]byte, error)
func (RawMessage) MarshalYAML ¶
func (m RawMessage) MarshalYAML() ([]byte, error)
func (*RawMessage) UnmarshalJSON ¶
func (m *RawMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
func (*RawMessage) UnmarshalYAML ¶
func (m *RawMessage) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements the yaml.Unmarshaler interface for YAMLRawMessage.
type Rule ¶
type Rule struct { Key string `json:"key" yaml:"key"` //唯一标识 Name string `json:"name" yaml:"name"` //名称 Desc string `json:"desc" yaml:"desc"` //描述 Version string `json:"version" yaml:"version"` //版本 Parallel bool `json:"parallel" yaml:"parallel"` //是否并发执行 Compares map[string]*Compare `json:"compares" yaml:"compares"` //比较 Expression string `json:"expression" yaml:"expression"` //计算公式 ActionTure []RawMessage `json:"action_true" yaml:"action_true"` ActionFalse []RawMessage `json:"action_false" yaml:"action_false"` }
type Ruleset ¶
type Ruleset struct { Key string `json:"key" yaml:"key"` //唯一标识 Name string `json:"name" yaml:"name"` //名称 Desc string `json:"desc" yaml:"desc"` //描述 Version string `yaml:"version" json:"version"` //版本 Parallel bool `json:"parallel" yaml:"parallel"` //是否并发执行 Rules []*rulesetRule `json:"rules" yaml:"rules"` }
type ValueInterface ¶
type Variate ¶
type Variate struct { Key string `json:"key" yaml:"key"` //唯一标识 Name string `json:"name" yaml:"name"` //变量名称 Desc string `json:"desc" yaml:"desc"` //描述 Version string `json:"version" yaml:"version"` //版本 ValueType ValueType `json:"value_type" yaml:"value_type"` //值类型 Default interface{} `json:"default" yaml:"default"` //默认值 IsInput bool `json:"is_input" yaml:"is_input"` //是否要从输入值中匹配 }
Click to show internal directories.
Click to hide internal directories.