Documentation
¶
Index ¶
- Constants
- func GetServerVersion(cfg *config.Config) (string, string, error)
- func ValidateClientVersion(clientVersion string) error
- type ClientHandshakePacket
- type ConnWrap
- func (cw *ConnWrap) ClientHandshake(modeName string, submode string, appRunId string, isTcp bool) (*ServerHandshakeResponse, error)
- func (cw *ConnWrap) Close() error
- func (cw *ConnWrap) GetServerVersion(isTcp bool) (string, error)
- func (cw *ConnWrap) ReadLine() (string, error)
- func (cw *ConnWrap) ServerHandshake(webServerPort int, isTcp bool) (*ClientHandshakePacket, error)
- func (cw *ConnWrap) WriteLine(line string) error
- type ConnectAddr
- type ServerHandshakePacket
- type ServerHandshakeResponse
Constants ¶
const ( ConnectionModePacket = "packet" ConnectionModeLog = "log" )
Connection mode constants
const ConnectDialTimeout = 500 * time.Millisecond
const MinClientVersion = "v0.9.0"
const MinServerVersion = "v0.9.0"
Variables ¶
This section is empty.
Functions ¶
func GetServerVersion ¶ added in v0.9.0
GetServerVersion connects to the Outrig server, retrieves the server version, and closes the connection. It uses the provided configuration to determine connection addresses. Returns (version, peerAddr, error).
func ValidateClientVersion ¶ added in v0.9.0
ValidateClientVersion validates that the client version meets minimum requirements
Types ¶
type ClientHandshakePacket ¶ added in v0.2.0
type ClientHandshakePacket struct {
OutrigSDK string `json:"outrigsdk"`
Mode string `json:"mode"`
Submode string `json:"submode,omitempty"`
AppRunID string `json:"apprunid,omitempty"`
}
ClientHandshakePacket represents the JSON structure for client handshake
type ConnWrap ¶
type ConnWrap struct {
Conn net.Conn
Reader *bufio.Reader
PeerName string
ServerResponse *ServerHandshakeResponse // set on client side connections
}
ConnWrap wraps a net.Conn and a bufio.Reader for convenient line-based communication.
func Connect ¶
func Connect(mode string, submode string, appRunId string, cfg *config.Config) (*ConnWrap, error, error)
Connect attempts to connect to addresses based on the provided config, performs the handshake with the specified mode, submode, and appRunId, and returns a new ConnWrap if successful.
It tries each address in order using the structured ConnectAddr information. When no valid addresses are available, the function returns (nil, nil, nil) without error.
The function returns (ConnWrap, PermanentError, TransientError)
func MakeConnWrap ¶
MakeConnWrap creates a new ConnWrap from a net.Conn.
func (*ConnWrap) ClientHandshake ¶
func (cw *ConnWrap) ClientHandshake(modeName string, submode string, appRunId string, isTcp bool) (*ServerHandshakeResponse, error)
ClientHandshake performs the client side of the handshake protocol with the server. If isTcp is true, the client first sends "OUTRIG\n" to identify itself as an Outrig client. It then receives a ServerHandshakePacket, validates compatibility, sends a ClientHandshakePacket, and processes the server's response.
func (*ConnWrap) GetServerVersion ¶ added in v0.9.0
GetServerVersion reads the server handshake packet and returns the server version. This method assumes the connection is already established and positioned to read the server handshake. For TCP connections, the caller should send "!OUTRIG" first if needed.
func (*ConnWrap) ServerHandshake ¶
func (cw *ConnWrap) ServerHandshake(webServerPort int, isTcp bool) (*ClientHandshakePacket, error)
ServerHandshake performs the server side of the handshake protocol. If isTcp is true, it first reads the "OUTRIG\n" identifier from TCP clients. It then sends a ServerHandshakePacket, reads a ClientHandshakePacket, validates it, and sends a response.
type ConnectAddr ¶ added in v0.8.0
func MakeConnectAddrs ¶ added in v0.8.0
func MakeConnectAddrs(cfg *config.Config) []ConnectAddr
MakeConnectAddrs builds the list of connection addresses based on config and environment variables
func (ConnectAddr) IsTcp ¶ added in v0.8.0
func (ca ConnectAddr) IsTcp() bool
type ServerHandshakePacket ¶ added in v0.2.0
type ServerHandshakePacket struct {
OutrigVersion string `json:"outrigversion"`
}