github.com/netdata/go.d.plugin@v0.58.1/pkg/socket/types.go (about) 1 // SPDX-License-Identifier: GPL-3.0-or-later 2 3 package socket 4 5 import ( 6 "crypto/tls" 7 "time" 8 ) 9 10 // Processor function passed to the Socket.Command function. 11 // It is passed by the caller to process a command's response 12 // line by line. 13 type Processor func([]byte) bool 14 15 // Client is the interface that wraps the basic socket client operations 16 // and hides the implementation details from the users. 17 // 18 // Connect should prepare the connection. 19 // 20 // Disconnect should stop any in-flight connections. 21 // 22 // Command should send the actual data to the wire and pass 23 // any results to the processor function. 24 // 25 // Implementations should return TCP, UDP or Unix ready sockets. 26 type Client interface { 27 Connect() error 28 Disconnect() error 29 Command(command string, process Processor) error 30 } 31 32 // Config holds the network ip v4 or v6 address, port, 33 // Socket type(ip, tcp, udp, unix), timeout and TLS configuration 34 // for a Socket 35 type Config struct { 36 Address string 37 ConnectTimeout time.Duration 38 ReadTimeout time.Duration 39 WriteTimeout time.Duration 40 TLSConf *tls.Config 41 }