Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MulticastCommunicator ¶
type MulticastCommunicator interface { // Listen starts the listener loop responsible for reading messages from the // multicast network and sending data read to the provided delegate. This // method will block the current calling routine until Shutdown is called. Listen() // Write writes a given buffer to the Multicast network. Write(data []byte) error // Shutdown starts the shutdown process for the current // MulticastCommunicator. It is safe to call this method multiple times. Shutdown() }
MulticastCommunicator abstracts a common set of methods implemented by components responsible for reading and writing UDP messages over the Multicast network.
func NewMulticastCommunicator ¶
func NewMulticastCommunicator(logger *zap.Logger, multicastAddress string, multicastPort uint16, ipProto proto.AddressKind, delegate MulticastCommunicatorDelegate) (MulticastCommunicator, error)
NewMulticastCommunicator returns a new MulticastCommunicator
type MulticastCommunicatorDelegate ¶
type MulticastCommunicatorDelegate interface { // LocalIPs is responsible for returning a list of all local IP addresses. LocalIPs() *iputil.IPList // HandleMulticastMessage is responsible for interpreting and handling a // given message received from the Multicast network. HandleMulticastMessage(listener MulticastCommunicator, data []byte, source net.IP) }
MulticastCommunicatorDelegate implements a component capable of responding to requests from the MulticastCommunicator.
type TCPControlClient ¶
type TCPControlClient interface { // Write writes the provided proto.TCPPacket to the client's socket Write(data *proto.TCPPacket) error // Close closes the client socket and stops all associated routines Close() // Source returns the TCP Address of the remote client Source() *net.TCPAddr // Hijack prevents incoming messages to be delivered to the default handler, // those being delivered instead directly to the channel returned by this // method. Hijack() chan *proto.TCPPacket }
TCPControlClient represents a client connected to a TCPControlServer
type TCPControlServer ¶
type TCPControlServer interface { // Start starts the server in a new routine. Start() // Shutdown signals the server to shut down and blocks the calling routine // until all clients disconnect. Shutdown() // Dial opens a new socket to a remote control server specified by addr Dial(addr proto.IP, port uint16) (TCPControlClient, error) }
TCPControlServer represents handler for TCP communications
func NewTCPControlServer ¶
func NewTCPControlServer(log *zap.Logger, address proto.IP, port uint16, delegate TCPControlServerDelegate) (TCPControlServer, error)
NewTCPControlServer returns a new TCPControlServer
type TCPControlServerDelegate ¶
type TCPControlServerDelegate interface {
HandleTCPPacket(server TCPControlServer, client TCPControlClient, tcpPkt *proto.TCPPacket)
}
TCPControlServerDelegate implements methods that allow handling of incoming data from a TCPControlClient accepted by a provided TCPControlServer.
type UDPControlServer ¶
type UDPControlServer interface { // Listen starts the server on the calling routine, blocking until it is // shutdown. Listen() // Shutdown signals the server to shut down, unblocking the routine that ' // invoked Listen Shutdown() // WriteUDP writes a given data buffer to the specified address and port. // Returns the amount of bytes written, or an error WriteUDP(target *net.UDPAddr, data []byte) (int, error) }
UDPControlServer represents a component responsible for reading incoming UDP requests from other nodes.
func NewUDPControlServer ¶
func NewUDPControlServer(logger *zap.Logger, address proto.IP, swimPort uint16, delegate UDPControlServerDelegate) (UDPControlServer, error)
NewUDPControlServer returns a new UDPControlServer
type UDPControlServerDelegate ¶
type UDPControlServerDelegate interface {
HandleUDPControlMessage(server UDPControlServer, data []byte, source *net.UDPAddr)
}
UDPControlServerDelegate implements methods that allow handling of incoming data from a UDPControlServer.