Documentation
¶
Index ¶
Constants ¶
const ( ModePrefix = "MODE:" OkResponse = "OK" ErrorPrefix = "ERROR" )
Constants for handshake protocol
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnWrap ¶
ConnWrap wraps a net.Conn and a bufio.Reader for convenient line-based communication.
func Connect ¶
func Connect(mode string, submode string, appRunId string, domainSocketPath string, serverAddr string) (*ConnWrap, error)
Connect attempts to connect to either a domain socket or TCP server, performs the handshake with the specified mode, submode, and appRunId, and returns a new ConnWrap if successful.
If domainSocketPath is not empty, it will first try to connect to the domain socket. If that fails and serverAddr is not empty, it will fall back to TCP. If both are empty or "-", it will return nil and an error.
The function returns a new ConnWrap and error. If the connection is successful, the error will be nil. If the connection fails, the error will contain the reason.
func MakeConnWrap ¶
MakeConnWrap creates a new ConnWrap from a net.Conn.
func (*ConnWrap) ClientHandshake ¶
ClientHandshake performs the client side of the mode-based handshake protocol with the server. It sends a mode line in the format "MODE:[mode]:[submode] [apprunid]\n" and expects an "OK\n" response from the server. If the server responds with an error, it returns that error. The submode is optional and can be empty.
func (*ConnWrap) ServerHandshake ¶
ServerHandshake performs the server side of the mode-based handshake protocol. It reads a mode line in the format "MODE:[mode]:[submode] [apprunid]\n", validates it, and sends an "OK\n" response if valid or an error message if invalid. It returns the mode, submode, and appRunId if successful, or an error if the handshake fails. The submode is optional and can be empty.