inject

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: 10 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 inject contains the inject node implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InjectConfig

type InjectConfig struct {
	// Payload is the message data — interpreted per PayloadType
	Payload string `json:"payload"`
	// PayloadType selects how Payload is interpreted: "timestamp"
	// (current time in ms, Node-RED's default), "date" (same),
	// "json" (parsed), "string"/"str" (literal text), "num" (parsed
	// number), "bool" ("true"/"false"), or "env" (Payload names the
	// environment variable to read). Empty defaults to timestamp when
	// no payload is configured, json otherwise.
	PayloadType string `json:"payloadType"`
	// Topic is stamped into Metadata["topic"] on every injected message
	// (Node-RED msg.topic)
	Topic string `json:"topic"`
	// Once fires the payload immediately on deploy
	Once bool `json:"once"`
	// Interval is the repeat period (0 = no repeat), in IntervalUnits
	Interval float64 `json:"interval"`
	// IntervalUnits scales Interval: "s" (default) | "min" | "hr" | "day"
	IntervalUnits string `json:"intervalUnits"`
}

InjectConfig holds configuration for the inject node

type InjectNode

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

InjectNode is a trigger that fires a configured payload once on deploy and/or repeatedly on an interval. Injects are fire-and-forget: no response is expected, so each message's pending entry is discarded right after injection (InjectMessage registers a pending channel keyed by msgID that nothing would otherwise resolve).

func NewInjectNode

func NewInjectNode(node nodestore.NodeInterface, config *InjectConfig, host nodebase.NodeHost) *InjectNode

NewInjectNode creates a new inject node

func (*InjectNode) Execute

Execute parses the configured payload once, then starts the firing goroutines (once-shot and/or interval ticker).

func (*InjectNode) Fire

func (n *InjectNode) Fire()

Fire injects a clone of the payload into the workflow — the host's FireInjectNode contract (a manual click on the inject button). Errors are ignored (e.g. the workflow may be undeploying). The pending response channel is discarded immediately — inject messages never get a reply.

func (*InjectNode) Stop

func (n *InjectNode) Stop() error

Stop halts the interval ticker (idempotent)

Jump to

Keyboard shortcuts

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