Documentation
¶
Overview ¶
Package batch contains the batch node implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchConfig ¶
type BatchConfig struct {
// Mode selects grouping: "count" batches every N messages,
// "interval" flushes everything buffered every Interval seconds,
// "concat" merges one complete parts sequence per configured topic
Mode string `json:"mode"`
// Count is the batch size for "count" mode
Count int `json:"count"`
// Overlap keeps the last N messages of a batch for the next batch
// ("count" mode)
Overlap int `json:"overlap"`
// Interval is the window length in seconds for "interval" mode
Interval float64 `json:"interval"`
// AllowEmptySequence emits an empty sequence message when an
// interval window closes with nothing buffered
AllowEmptySequence bool `json:"allowEmptySequence"`
// HonourParts flushes a count-mode batch early when an incoming
// parts sequence completes (parts.index+1 == parts.count)
HonourParts bool `json:"honourParts"`
// Topics lists the concat-mode topics in output order; each entry
// is {"topic": "..."} as serialized by Node-RED
Topics []struct {
Topic string `json:"topic"`
} `json:"topics"`
}
BatchConfig holds configuration for the batch node — the Node-RED batch equivalent. Buffers messages and re-emits them as a parts sequence (count/interval) or concatenates topic sequences (concat).
type BatchNode ¶
BatchNode re-emits buffered messages as a parts sequence. Buffered messages are dropped (nil return); completed batches go downstream asynchronously through the node's outgoing edges.
func NewBatchNode ¶
func NewBatchNode(node nodestore.NodeInterface, config *BatchConfig, host nodebase.NodeHost) *BatchNode
NewBatchNode creates a new batch node
func (*BatchNode) Execute ¶
func (n *BatchNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute buffers the message and, when a batch completes, emits the sequence asynchronously — the triggering message itself is dropped.