Documentation
¶
Overview ¶
Package sort contains the sort node implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SortConfig ¶
type SortConfig struct {
// Order is "ascending" (default) or "descending" — the "asc"/"desc"
// spellings from older serialization are also accepted
Order string `json:"order"`
// AsNum coerces compared values to numbers first (serialized "as_num")
AsNum bool `json:"as_num"`
// Target is the msg-target property path holding the array to
// sort (default "payload"); ignored for seq target
Target string `json:"target"`
// TargetType selects the sort target: "msg" sorts the array at
// Target in place, "seq" sorts a parts sequence by SeqKey
TargetType string `json:"targetType"`
// MsgKey is the msg-target element key: msgKeyType "jsonata"
// evaluates it against each element, anything else compares the
// elements themselves
MsgKey string `json:"msgKey"`
// MsgKeyType is "elem" (compare elements) or "jsonata"
MsgKeyType string `json:"msgKeyType"`
// SeqKey is the seq-target sort key: seqKeyType "msg" reads a
// message property path, "jsonata" evaluates it against the message
SeqKey string `json:"seqKey"`
// SeqKeyType is "msg" or "jsonata"
SeqKeyType string `json:"seqKeyType"`
}
SortConfig holds configuration for the sort node — the Node-RED sort equivalent (order/as_num/targetType/msgKey/seqKey fields).
type SortNode ¶
SortNode sorts either a payload array in place ("msg" target) or a buffered parts sequence re-emitted in order ("seq" target).
func NewSortNode ¶
func NewSortNode(node nodestore.NodeInterface, config *SortConfig, host nodebase.NodeHost) *SortNode
NewSortNode creates a new sort node
func (*SortNode) Execute ¶
func (n *SortNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute sorts a payload array in place (msg target) or buffers a parts sequence until complete (seq target), re-emitting the sorted messages asynchronously in order and dropping the current one.