mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 10:58:35 +08:00
规则引擎
This commit is contained in:
35
pkg/rule_engine/nodes/input_node.go
Normal file
35
pkg/rule_engine/nodes/input_node.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package nodes
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"pandax/pkg/rule_engine/message"
|
||||
)
|
||||
|
||||
const InputNodeName = "InputNode"
|
||||
|
||||
type inputNode struct {
|
||||
bareNode
|
||||
}
|
||||
|
||||
type inputNodeFactory struct{}
|
||||
|
||||
func (f inputNodeFactory) Name() string { return "InputNode" }
|
||||
func (f inputNodeFactory) Category() string { return NODE_CATEGORY_OTHERS }
|
||||
|
||||
func (f inputNodeFactory) Create(id string, meta Metadata) (Node, error) {
|
||||
labels := []string{}
|
||||
node := &inputNode{
|
||||
bareNode: newBareNode(InputNodeName, id, meta, labels),
|
||||
}
|
||||
return node, nil
|
||||
}
|
||||
|
||||
func (n *inputNode) Handle(msg message.Message) error {
|
||||
logrus.Infof("%s handle message '%s'", n.Name(), msg.GetType())
|
||||
|
||||
nodes := n.GetLinkedNodes()
|
||||
for _, node := range nodes {
|
||||
return node.Handle(msg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user