Documentation
¶
Overview ¶
Package trigger contains the trigger node implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TriggerConfig ¶
type TriggerConfig struct {
// Op1 / Op1Type configure the value emitted immediately on output_1.
// Types: str (default) | num | bool | json | payload (pass input through).
Op1 string `json:"op1"`
Op1Type string `json:"op1type"`
// Op2 / Op2Type configure the value emitted when the timer expires.
Op2 string `json:"op2"`
Op2Type string `json:"op2type"`
// Duration is the delay before op2 fires (0 = no second message).
Duration float64 `json:"duration"`
// Units is the duration unit: ms (default) | s | min | hr.
Units string `json:"units"`
// Extend restarts the pending timer on each new message.
Extend bool `json:"extend"`
// OverrideDelay lets Metadata["delay"] replace the configured
// duration (same units).
OverrideDelay bool `json:"overrideDelay"`
// Outputs selects where op2 goes: 1 = output_1, 2 = output_2.
Outputs int `json:"outputs"`
// ByTopic keeps a separate timer per Metadata["topic"].
ByTopic bool `json:"bytopic"`
}
TriggerConfig holds configuration for the trigger node — the Node-RED trigger equivalent (simplified field names).
type TriggerNode ¶
TriggerNode sends one message immediately, then optionally a second after a configurable delay — the Node-RED trigger node. The immediate output always routes to output_1 (via SelectPorts); the delayed output is emitted asynchronously on output_2 (outputs=2) or output_1. Metadata["reset"] clears pending timers and drops the message.
func NewTriggerNode ¶
func NewTriggerNode(node nodestore.NodeInterface, config *TriggerConfig, host nodebase.NodeHost) *TriggerNode
NewTriggerNode creates a new trigger node
func (*TriggerNode) Execute ¶
func (n *TriggerNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute emits op1 immediately (returned as the output, routed to output_1 by SelectPorts) and arms/rearms the op2 timer. A truthy Metadata["reset"] clears pending timers and drops the message.
func (*TriggerNode) SelectPorts ¶
func (n *TriggerNode) SelectPorts(input, output nodestore.MessageInterface) []string
SelectPorts routes the immediate output (op1) to output_1 only.
func (*TriggerNode) Validate ¶
func (n *TriggerNode) Validate() error
Validate checks the trigger node configuration