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 {
// Host is the remote host (default 127.0.0.1).
Host string `json:"host"`
// Port is the remote port.
Port int `json:"port"`
// Ret selects the reply payload type: "string" (default) | "buffer"
// (raw []byte). Node-RED field name: ret.
Ret string `json:"ret"`
// Mode selects the reply framing: "timeout" (default — take
// whatever arrives before Timeout), "delimiter" (read until the
// delimiter bytes appear) or "length" (read exactly Length bytes).
Mode string `json:"mode"`
// Timeout bounds connect + reply wait, in seconds (default 10;
// 0 = 10).
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"`
// 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