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 ¶
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 ¶
func (n *InjectNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
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)