规则链

This commit is contained in:
XM-GO
2023-04-17 17:18:15 +08:00
10 changed files with 138 additions and 68 deletions

View File

@@ -0,0 +1,29 @@
package nodes
import (
"log"
"pandax/pkg/rule_engine/message"
)
type MyNode struct {
bareNode
}
type myNodeFactory struct{}
func (f myNodeFactory) Name() string { return "MyNode" }
func (f myNodeFactory) Category() string { return NODE_CATEGORY_ACTION }
func (f myNodeFactory) Labels() []string { return []string{"Next", "Next2"} }
func (f myNodeFactory) Create(id string, meta Metadata) (Node, error) {
node := &MyNode{
bareNode: newBareNode(f.Name(), id, meta, f.Labels()),
}
return decodePath(meta, node)
}
func (n *MyNode) Handle(msg message.Message) error {
nextLableNode := n.GetLinkedNode("Next")
log.Println(nextLableNode.Name())
return nil
}

View File

@@ -31,4 +31,6 @@ func init() {
RegisterFactory(externalSendSmsNodeFactory{})
RegisterFactory(externalRuleChainNodeFactory{})
RegisterFactory(myNodeFactory{})
}

View File

@@ -15,7 +15,7 @@ type inputNodeFactory struct{}
func (f inputNodeFactory) Name() string { return "InputNode" }
func (f inputNodeFactory) Category() string { return NODE_CATEGORY_OTHERS }
func (f inputNodeFactory) Labels() []string { return []string{} }
func (f inputNodeFactory) Labels() []string { return []string{"True"} }
func (f inputNodeFactory) Create(id string, meta Metadata) (Node, error) {
node := &inputNode{
bareNode: newBareNode(InputNodeName, id, meta, f.Labels()),