Documentation ¶
Overview ¶
Package thwack provides a trivial text based management protocol.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandHandlerFn ¶
CommandHandlerFn is a command handler hook function. Each handler function is responsible for fully handling a command and sending a response, and MUST NOT return an error unless the connection is to be closed immediately.
type Config ¶
type Config struct {
// Net and Addr specify the network and address of the server instance.
Net, Addr string
// ServiceName is the service name to be displayed in the greeting banner.
ServiceName string
// LogModule is the module for the Server's Logger.
LogModule string
// NewLoggerFn is the function to call to construct per-connection Loggers.
NewLoggerFn func(string) *logging.Logger
}
Config is a thwack Server configuration.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a thwack connection instance.
func (*Conn) Log ¶
func (c *Conn) Log() *logging.Logger
Log returns the per-connection logging.Logger.
func (*Conn) SetState ¶
func (c *Conn) SetState(state interface{})
SetState sets the per-connection state.
func (*Conn) WriteReply ¶
func (c *Conn) WriteReply(status StatusCode) error
WriteReply is a convenience routine for sending a StatusCode and human readable reason to the peer.
type Server ¶
Server is a thwack server instance.
func (*Server) RegisterCommand ¶
func (s *Server) RegisterCommand(cmd string, fn CommandHandlerFn)
RegisterCommand sets the handler function for the specified command. This MUST NOT be called after the Server has been started with Start().
type StatusCode ¶
type StatusCode int
StatusCode is a thwack status code.
const ( // StatusServiceReady is the status code that is always sent on a new // connection to signify that the management interface is ready. StatusServiceReady StatusCode = 220 // StatusOk is the status code returned to signal successful completion // of a command. StatusOk StatusCode = 250 // StatusUnknownCommand is the status code returned when a command is // unknown. StatusUnknownCommand StatusCode = 500 // StatusSyntaxError is the status code returned when the syntax of a // command or it's argument(s) is invalid. StatusSyntaxError StatusCode = 501 // StatusTransactionFailed is the status code returned when the command // has failed. StatusTransactionFailed StatusCode = 554 )