Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connection ¶
Connection returns the underlying connection used in calls to function in a Handler.
func ListenAndServe ¶
Types ¶
type ControlMessageType ¶
type ControlMessageType byte
ControlMessageType represents the control message types. There exists five types of such control messages: +------------+--------------------------------------------------------+ | type byte | signification | +------------+--------------------------------------------------------+ | 0 | synchronisation request: ask a remote peer for a full | | | synchronization | +------------+--------------------------------------------------------+ | 1 | synchronization finished: signal a remote peer that | | | local updates have been pushed and local is considered | | | up to date. | +------------+--------------------------------------------------------+ | 2 | synchronization partial: signal a remote peer that | | | local updates have been pushed and local is not | | | considered up to date. | +------------+--------------------------------------------------------+ | 3 | synchronization confirmed: acknowledge a finished or | | | partial synchronization message. | +------------+--------------------------------------------------------+ | 4 | Heartbeat message. | +------------+--------------------------------------------------------+
const ( // PEER_MSG_CTRL_RESYNCREQ = 0, ControlMessageSyncRequest ControlMessageType = iota // PEER_MSG_CTRL_RESYNCFINISHED, ControlMessageSyncFinished // PEER_MSG_CTRL_RESYNCPARTIAL, ControlMessageSyncPartial // PEER_MSG_CTRL_RESYNCCONFIRM, ControlMessageSyncConfirmed // PEER_MSG_CTRL_HEARTBEAT, ControlMessageHeartbeat )
Control messages
func (ControlMessageType) OnMessage ¶
func (t ControlMessageType) OnMessage(m *rawMessage, c *protocolClient) error
func (ControlMessageType) String ¶
func (i ControlMessageType) String() string
type ErrorMessageType ¶
type ErrorMessageType byte
ErrorMessageType represents the error message types. There exits two types of such error messages: +-----------+------------------+ | type byte | signification | +-----------+------------------+ | 0 | protocol error | +-----------+------------------+ | 1 | size limit error | +-----------+------------------+
const ( // PEER_MSG_ERR_PROTOCOL = 0, ErrorMessageProtocol ErrorMessageType = iota // PEER_MSG_ERR_SIZELIMIT, ErrorMessageSizeLimit )
Error messages
func (ErrorMessageType) OnMessage ¶
func (t ErrorMessageType) OnMessage(m *rawMessage, c *protocolClient) error
func (ErrorMessageType) String ¶
func (i ErrorMessageType) String() string
type Handler ¶
type Handler interface {
HandleUpdate(context.Context, *sticktable.EntryUpdate)
HandleHandshake(context.Context, *Handshake)
Close() error
}
type HandlerFunc ¶
type HandlerFunc func(context.Context, *sticktable.EntryUpdate)
func (HandlerFunc) Close ¶
func (HandlerFunc) Close() error
func (HandlerFunc) HandleHandshake ¶
func (HandlerFunc) HandleHandshake(context.Context, *Handshake)
func (HandlerFunc) HandleUpdate ¶
func (h HandlerFunc) HandleUpdate(ctx context.Context, u *sticktable.EntryUpdate)
type Handshake ¶
type Handshake struct {
ProtocolIdentifier string
Version string
RemotePeer string
LocalPeerIdentifier string
ProcessID int
RelativeProcessID int
}
Handshake is composed by these fields:
protocol identifier : HAProxyS version : 2.1 remote peer identifier: the peer name this "hello" message is sent to. local peer identifier : the name of the peer which sends this "hello" message. process ID : the ID of the process handling this peer session. relative process ID : the haproxy's relative process ID (0 if nbproc == 1).
func NewHandshake ¶
NewHandshake returns a basic handshake to be used for connecting to haproxy peers. It is filled with all necessary information except the remote peer hostname.
type HandshakeStatus ¶
type HandshakeStatus int
HandshakeStatus represents the Handshake States +-------------+---------------------------------+ | status code | signification | +-------------+---------------------------------+ | 200 | Handshake succeeded | +-------------+---------------------------------+ | 300 | Try again later | +-------------+---------------------------------+ | 501 | Protocol error | +-------------+---------------------------------+ | 502 | Bad version | +-------------+---------------------------------+ | 503 | Local peer identifier mismatch | +-------------+---------------------------------+ | 504 | Remote peer identifier mismatch | +-------------+---------------------------------+
const ( HandshakeStatusHandshakeSucceeded HandshakeStatus = 200 HandshakeStatusTryAgainLater HandshakeStatus = 300 HandshakeStatusProtocolError HandshakeStatus = 501 HandshakeStatusBadVersion HandshakeStatus = 502 HandshakeStatusLocalPeerIdentifierMismatch HandshakeStatus = 503 HandshakeStatusRemotePeerIdentifierMismatch HandshakeStatus = 504 )
func (HandshakeStatus) String ¶
func (i HandshakeStatus) String() string
type MessageClass ¶
type MessageClass byte
MessageClass represents the message classes. There exist four classes of messages: +------------+---------------------+--------------+ | class byte | signification | message size | +------------+---------------------+--------------+ | 0 | control | fixed (2) | +------------+---------------------+--------------| | 1 | error | fixed (2) | +------------+---------------------+--------------| | 10 | stick-table updates | variable | +------------+---------------------+--------------| | 255 | reserved | | +------------+---------------------+--------------+
const ( // PEER_MSG_CLASS_CONTROL = 0, MessageClassControl MessageClass = iota // PEER_MSG_CLASS_ERROR, MessageClassError // PEER_MSG_CLASS_STICKTABLE = 0x0a, MessageClassStickTableUpdates MessageClass = 10 // PEER_MSG_CLASS_RESERVED = 0xff, MessageClassReserved MessageClass = 255 )
HAPPP message classes
func (MessageClass) String ¶
func (i MessageClass) String() string
type Peer ¶
type Peer struct {
Handler Handler
HandlerSource func() Handler
BaseContext context.Context
Addr string
}
func (*Peer) ListenAndServe ¶
type StickTableUpdateMessageType ¶
type StickTableUpdateMessageType byte
StickTableUpdateMessageType represents the stick-table update message types. There exist five types of such stick-table update messages: +-----------+--------------------------------+ | type byte | signification | +-----------+--------------------------------+ | 128 | Entry update | +-----------+--------------------------------+ | 129 | Incremental entry update | +-----------+--------------------------------+ | 130 | Stick-table definition | +-----------+--------------------------------+ | 131 | Stick-table switch (unused) | +-----------+--------------------------------+ | 132 | Update message acknowledgement | +-----------+--------------------------------+
const ( StickTableUpdateMessageTypeEntryUpdate StickTableUpdateMessageType = iota + 0x80 StickTableUpdateMessageTypeIncrementalEntryUpdate StickTableUpdateMessageTypeStickTableDefinition StickTableUpdateMessageTypeStickTableSwitch StickTableUpdateMessageTypeUpdateAcknowledge StickTableUpdateMessageTypeUpdateTimed StickTableUpdateMessageTypeIncrementalEntryUpdateTimed )
Stick table messages
func (StickTableUpdateMessageType) OnMessage ¶
func (t StickTableUpdateMessageType) OnMessage(m *rawMessage, c *protocolClient) error
func (StickTableUpdateMessageType) String ¶
func (i StickTableUpdateMessageType) String() string