mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
规则链
This commit is contained in:
29
pkg/rule_engine/nodes/action_my_node.go
Normal file
29
pkg/rule_engine/nodes/action_my_node.go
Normal 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
|
||||
}
|
||||
@@ -31,4 +31,6 @@ func init() {
|
||||
RegisterFactory(externalSendSmsNodeFactory{})
|
||||
RegisterFactory(externalRuleChainNodeFactory{})
|
||||
|
||||
RegisterFactory(myNodeFactory{})
|
||||
|
||||
}
|
||||
|
||||
@@ -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()),
|
||||
|
||||
Reference in New Issue
Block a user