Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicStatus ¶
type BasicStatus struct {
// contains filtered or unexported fields
}
BasicStatus stores metadata of a Connection or a Stream.
func (*BasicStatus) Closed ¶
func (s *BasicStatus) Closed() bool
Closed returns whether the connection is closed.
func (*BasicStatus) Direction ¶
func (s *BasicStatus) Direction() Direction
Direction returns the direction of the connection.
func (*BasicStatus) EstablishedTime ¶
func (s *BasicStatus) EstablishedTime() time.Time
EstablishedTime returns the time when the connection was established.
func (*BasicStatus) Extra ¶
func (s *BasicStatus) Extra() map[interface{}]interface{}
Extra returns the extra metadata of the connection.
func (*BasicStatus) SetClosed ¶
func (s *BasicStatus) SetClosed()
SetClosed marks the connection as closed.
type Connection ¶
type Connection interface { io.Closer Status // LocalAddr returns the local net multi-address of the connection. LocalAddr() ma.Multiaddr // LocalNetAddr returns the local net address of the connection. LocalNetAddr() net.Addr // LocalPeerID returns the local peer ID of the connection. LocalPeerID() peer.ID // RemoteAddr returns the remote net multi-address of the connection. RemoteAddr() ma.Multiaddr // RemoteNetAddr returns the remote net address of the connection. RemoteNetAddr() net.Addr // RemotePeerID returns the remote peer ID of the connection. RemotePeerID() peer.ID // Network returns the network instance that created this connection. Network() Network // OpenSendStream tries to open a sending stream with the connection. OpenSendStream() (SendStream, error) // AcceptReceiveStream accepts a receiving stream with the connection. // It will block until a new receiving stream is accepted or the connection is closed. AcceptReceiveStream() (ReceiveStream, error) }
Connection defines a connection with a remote peer.
type Dialer ¶
type Dialer interface { // Dial tries to establish an outbound connection with the remote address. Dial(ctx context.Context, remoteAddr ma.Multiaddr) (Connection, error) }
Dialer provides a way to establish a connection with others.
type Listener ¶
type Listener interface { io.Closer // Listen runs a task that creates listeners with the given addresses and waits for accepting inbound connections. // It returns an error if there is any issue starting the listeners. Listen(ctx context.Context, addresses ...ma.Multiaddr) error // ListenAddresses returns the list of local addresses for the listeners. ListenAddresses() []ma.Multiaddr }
Listener provides a way to accept connections established with others.
type Network ¶
type Network interface { Dialer Listener io.Closer // AcceptedConnChan returns a channel for notifying about new connections. // Whenever a new connection is accepted or dialed, Network should write the new connection to chan. AcceptedConnChan() <-chan Connection // Disconnect closes a connection. Disconnect(conn Connection) error // Closed returns whether the network is closed. Closed() bool // LocalPeerID returns the local peer ID. LocalPeerID() peer.ID // Logger returns the logger instance. Logger() *rainbowlog.Logger }
Network is a state machine interface that provides a Dialer and a Listener to build a network.
type ReceiveStream ¶
ReceiveStream is an interface that defines a way to receive data.
type SendStream ¶
SendStream is an interface that defines a way to send data.