Documentation
¶
Overview ¶
Package switchnode contains the switch node implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SwitchConfig ¶
type SwitchConfig struct {
Rules []nodebase.SwitchRule `json:"rules"`
Mode string `json:"mode"` // first | all (default "first")
// Otherwise adds a dedicated port after the last rule output; a
// message matching no rule is routed there (Node-RED "otherwise").
Otherwise bool `json:"otherwise"`
}
SwitchConfig holds configuration for the switch node
type SwitchNode ¶
SwitchNode routes the message to one of several output ports based on rules evaluated against the payload — the Node-RED switch equivalent. The node itself is a pass-through; routing happens via SelectPorts.
func NewSwitchNode ¶
func NewSwitchNode(node nodestore.NodeInterface, config *SwitchConfig) *SwitchNode
NewSwitchNode creates a new switch node
func (*SwitchNode) Execute ¶
func (n *SwitchNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute passes the input through unchanged — routing is done by the host via SelectPorts
func (*SwitchNode) SelectPorts ¶
func (n *SwitchNode) SelectPorts(input, output nodestore.MessageInterface) []string
SelectPorts evaluates the configured rules in order against the input payload and returns the matching output port keys. "first" mode stops at the first match; "all" returns every matching port. No match returns an empty slice — the message dies at this node.
func (*SwitchNode) Validate ¶
func (n *SwitchNode) Validate() error
Validate rejects bad rule configuration at deploy time (project policy: unsupported features fail loudly, not silently at message time).