Documentation
¶
Overview ¶
Package tcprequest contains the tcpRequest node implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TCPRequestConfig ¶
type TCPRequestConfig struct {
// Server is the Node-RED host field ("" falls back to Host).
Server string `json:"server"`
// Host is the legacy host field (default 127.0.0.1).
Host string `json:"host"`
// Port is the remote port; message metadata "port" overrides it
// (Node-RED msg.port semantics).
Port int `json:"port"`
// Ret selects the reply payload type: "string" (default) | "buffer"
// (raw []byte). Node-RED field name: ret.
Ret string `json:"ret"`
// Out is the Node-RED close selector: "time" (reply after a
// timeout of Splitc ms), "char" (reply ends at the Splitc
// character), "count" (reply is exactly Splitc bytes), "sit"
// (stay connected — stream replies) or "immed" (send and
// close without waiting). "" falls back to the legacy Mode field.
Out string `json:"out"`
// Splitc is the Node-RED close parameter: milliseconds for
// "time", the delimiter character for "char", the byte count for
// "count". Serialized as a string by Node-RED.
Splitc string `json:"splitc"`
// Mode selects the reply framing: "timeout" (default — take
// whatever arrives before Timeout), "delimiter" (read until the
// delimiter bytes appear), "length" (read exactly Length bytes),
// "sit" (stay connected, stream replies) or "immed" (don't wait
// for a reply). The Node-RED Out field wins when set.
Mode string `json:"mode"`
// Timeout bounds connect + reply wait, in seconds (default 10;
// 0 = 10). Out "time" overrides it with Splitc milliseconds.
Timeout float64 `json:"timeout"`
// Delimiter terminates the reply in "delimiter" mode
// (escape sequences like \n allowed).
Delimiter string `json:"delimiter"`
// Length is the fixed reply size in "length" mode.
Length int `json:"length"`
// Newline delimits replies in "sit" mode when the return type is
// string (escape sequences like \n allowed).
Newline string `json:"newline"`
// Trim re-attaches the delimiter to each reply part in "sit"
// mode (Node-RED 're-attach' checkbox).
Trim bool `json:"trim"`
// Keep keeps the client connection open across messages instead of
// closing it after each request/reply (Node-RED's persistent
// client session). The connection is dropped on redeploy/stop.
Keep bool `json:"keep"`
// TLS names a tlsConfig node in the same workflow; when set the
// connection is upgraded to TLS with that material.
TLS string `json:"tls"`
}
TCPRequestConfig holds configuration for the tcpRequest node — the Node-RED `tcp request` equivalent: a client session that connects to a server, sends the payload and waits for the reply.
type TCPRequestNode ¶
TCPRequestNode sends the payload over a TCP connection and emits the server's reply as the message payload.
func NewTCPRequestNode ¶
func NewTCPRequestNode(node nodestore.NodeInterface, config *TCPRequestConfig, host nodebase.NodeHost) *TCPRequestNode
NewTCPRequestNode creates a new tcpRequest node
func (*TCPRequestNode) Execute ¶
func (n *TCPRequestNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute dials (or reuses a kept connection), writes the payload and reads the reply per the configured framing.
func (*TCPRequestNode) Validate ¶
func (n *TCPRequestNode) Validate() error
Validate checks the tcpRequest node configuration