Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { ID() string Send(message []byte, id []byte) Close() error LastOpTime() time.Time // last rw op time for this connection RemoteAddr() net.Addr }
Connection is a closeable network connection, that can send and receive messages from a remote instance. Connection is an io.Writer and an io.Closer.
type ConnectionError ¶
type ConnectionError struct { Connection Connection Err error ID []byte // optional outgoing message id }
ConnectionError specifies a connection error.
type ConnectionSource ¶
type ConnectionSource int
ConnectionSource specifies the connection originator - local or remote node.
const ( Local ConnectionSource = iota Remote )
ConnectionSource values.
type IncomingMessage ¶
type IncomingMessage struct { Connection Connection Message []byte }
IncomingMessage specifies incoming network message data.
type MessageSendError ¶
type MessageSendError struct { Connection Connection Message []byte Err error ID []byte }
MessageSendError defines an error condition for sending a message.
type MessageSentEvent ¶
type MessageSentEvent struct { Connection Connection ID []byte }
MessageSentEvent specifies a sent network message data.
type Net ¶
type Net interface { DialTCP(address string, timeOut time.Duration, keepAlive time.Duration) (Connection, error) // Connect to a remote node. Can send when no error. GetNewConnections() chan Connection GetClosingConnections() chan Connection GetConnectionErrors() chan ConnectionError GetIncomingMessage() chan IncomingMessage GetMessageSendErrors() chan MessageSendError GetMessageSentCallback() chan MessageSentEvent Shutdown() }
Net is a connection manager able to dial remote endpoints. Net clients should register all callbacks.
Connections may be initiated by DialTCP() or by remote clients connecting to the listen address. ConnManager includes a TCP server, and a TCP client.
It provides full duplex messaging functionality over the same tcp/ip connection. Network should not know about higher-level networking types such as remoteNode, swarm and networkSession. Network main client is the swarm. Net has no channel events processing loops - clients are responsible for polling these channels and popping events from them
type OutgoingMessage ¶
OutgoingMessage specifies an outgoing message data.