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