delay

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 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 delay contains the delay node implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DelayConfig

type DelayConfig struct {
	// PauseType selects the action: "delay" (fixed), "delayv" (delay
	// from a message property), "random" (uniform in a range) or "rate"
	// (rate limit). Legacy spellings "timed" and "queue" are aliases.
	PauseType string `json:"pauseType"`
	// Timeout is the fixed delay value; TimeoutUnits one of
	// milliseconds|seconds|minutes|hours.
	Timeout      interface{} `json:"timeout"`
	TimeoutUnits string      `json:"timeoutUnits"`
	// DelayPath names the message property read for the delay in
	// milliseconds in "delayv" mode (default "delay" → msg.delay).
	DelayPath string `json:"delayPath"`
	// RandomFirst/RandomLast bound the random delay range;
	// RandomUnits carries the unit.
	RandomFirst interface{} `json:"randomFirst"`
	RandomLast  interface{} `json:"randomLast"`
	RandomUnits string      `json:"randomUnits"`
	// Rate messages are allowed per NbRateUnits RateUnits; spread evenly.
	Rate        interface{} `json:"rate"`
	NbRateUnits interface{} `json:"nbRateUnits"`
	RateUnits   string      `json:"rateUnits"`
	// RateType scopes the limiter: "all" (one shared) or "topic"
	// (independent per msg.topic — intermediates auto-drop).
	RateType string `json:"rateType"`
	// Drop keeps only the most recent queued message in "all" mode.
	Drop bool `json:"drop"`
	// AllowRate lets a numeric msg.rate (ms) override the interval.
	AllowRate bool `json:"allowrate"`
	// Outputs is the node port count; 2 adds a second port that
	// receives messages the rate limiter discards (Node-RED burst
	// behaviour — dropped messages go to the second output).
	Outputs int `json:"outputs"`
	// Duration is the legacy config (milliseconds) kept so existing
	// flows keep working; pauseType fields take precedence when set.
	Duration int `json:"duration"`
}

DelayConfig holds the node's configuration. Numeric fields accept strings too — Node-RED serializes them as quoted values in exports, so they stay interface{} and are parsed through nodebase.ParseNumeric.

type DelayNode

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

DelayNode delays or rate-limits messages. Fixed/variable/random modes park the message on a timer and return immediately (Node-RED parity — sibling wires are not stalled while a message is held); rate mode returns the message when the window is free and otherwise queues it for a timed host.Emit.

func NewDelayNode

func NewDelayNode(node nodestore.NodeInterface, config *DelayConfig, host nodebase.NodeHost) *DelayNode

NewDelayNode creates a new delay node

func (*DelayNode) Execute

Execute applies the configured action. A truthy "reset" property clears all held messages without sending them; a "flush" property releases held messages immediately (all, or that many when numeric).

Jump to

Keyboard shortcuts

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