delay

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 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.

README

Delay node

Type: delay
Category: Flow Control

Delays each message or limits the rate at which they pass (Node-RED delay).

Behavior

This node is registered as delay and runs as part of a workflow. Its exact runtime behavior is implemented in node.go; this document summarizes the editor-facing purpose and configuration contract.

Configuration

Field Type Default Description
allowrate boolean false Allow msg.rate Override — A numeric msg.rate (in ms) replaces the interval until reset
delayPath string delay Delay Property — Message property holding the delay in milliseconds (e.g. "delay" for msg.delay)
drop boolean false Drop Intermediate Messages — Keep only the most recent message while rate-limited (off queues them all)
nbRateUnits number 1 Per
outputs integer 1 Outputs — 2 adds a second port that receives messages dropped by the rate limiter
pauseType string delay Action
randomFirst number 1 Between
randomLast number 5 And
randomUnits string seconds Units
rate integer 1 Rate — Messages allowed per rate period — they are spread evenly across it
rateType string all Apply To
rateUnits string second Rate Units
timeout number 5 For — Fixed delay before each message is released
timeoutUnits string seconds Units

Implementation

  • node.go contains the executor, validation, schema, and registration.
  • editor.html contains the editor integration.
  • node_test.go, when present, contains behavioral tests.

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