switchnode

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

type SwitchNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

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

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL