trigger

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: 8 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 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

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

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

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

Jump to

Keyboard shortcuts

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