Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnMgr ¶
type ConnMgr interface { io.Closer AddPeerConn(pid peer.ID, conn network.Conn) bool RemovePeerConn(pid peer.ID, conn network.Conn) bool ExistPeerConn(pid peer.ID, conn network.Conn) bool GetPeerConn(pid peer.ID) network.Conn GetPeerAllConn(pid peer.ID) []network.Conn IsConnected(pid peer.ID) bool IsAllowed(pid peer.ID) bool ExpendConn(pid peer.ID) MaxPeerCountAllowed() int PeerCount() int AllPeer() []peer.ID }
ConnMgr provides a connection manager.
type ConnSupervisor ¶
type ConnSupervisor interface { basic.Switcher // SetPeerAddr will set a peer as a necessary peer and store the peer's address. SetPeerAddr(pid peer.ID, addr ma.Multiaddr) // RemovePeerAddr will unset a necessary peer. RemovePeerAddr(pid peer.ID) // RemoveAllPeer clean all necessary peers. RemoveAllPeer() }
ConnSupervisor maintains the connection state of the necessary peers. If a necessary peer is not connected to us, supervisor will try to dial to it.
type ProtocolExchanger ¶
type ProtocolExchanger interface { // ProtocolID is the protocol.ID of exchanger service. // The protocol id will be registered in host.RegisterMsgPayloadHandler method. ProtocolID() protocol.ID // Handle is the msg payload handler of exchanger service. // It will be registered in host.Host.RegisterMsgPayloadHandler method. Handle() handler.MsgPayloadHandler // ExchangeProtocol will send protocols supported by us to the other and receive protocols supported by the other. // This method will be invoked during connection establishing. ExchangeProtocol(conn network.Conn) ([]protocol.ID, error) // PushProtocols will send protocols supported by us to the other. // This method will be invoked when new protocol registering. PushProtocols(pid peer.ID) error }
ProtocolExchanger usual be used to exchange protocols supported by both peers.
type ProtocolManager ¶
type ProtocolManager interface { // RegisterMsgPayloadHandler register a protocol supported by us // and map a handler.MsgPayloadHandler to this protocol. RegisterMsgPayloadHandler(protocolID protocol.ID, handler handler.MsgPayloadHandler) error // UnregisterMsgPayloadHandler unregister a protocol supported by us. UnregisterMsgPayloadHandler(protocolID protocol.ID) error // IsRegistered return whether a protocol given is supported by us. IsRegistered(protocolID protocol.ID) bool // GetHandler return the handler.MsgPayloadHandler mapped to the protocol supported by us and id is the given. // If the protocol not supported by us, return nil. GetHandler(protocolID protocol.ID) handler.MsgPayloadHandler // GetSelfSupportedProtocols return a list of protocol.ID that supported by myself. GetSelfSupportedProtocols() []protocol.ID // IsPeerSupported return whether the protocol is supported by peer which id is the given pid. // If peer not connected to us, return false. IsPeerSupported(pid peer.ID, protocolID protocol.ID) bool // GetPeerSupportedProtocols return a list of protocol.ID that supported by the peer which id is the given pid. GetPeerSupportedProtocols(pid peer.ID) []protocol.ID // SetPeerSupportedProtocols stores the protocols supported by the peer which id is the given pid. SetPeerSupportedProtocols(pid peer.ID, protocolIDs []protocol.ID) // CleanPeerSupportedProtocols remove all records of protocols supported by the peer which id is the given pid. CleanPeerSupportedProtocols(pid peer.ID) // SetProtocolSupportedNotifyFunc set a function for notifying peer protocol supporting. SetProtocolSupportedNotifyFunc(notifyFunc ProtocolSupportNotifyFunc) // SetProtocolUnsupportedNotifyFunc set a function for notifying peer protocol supporting canceled. SetProtocolUnsupportedNotifyFunc(notifyFunc ProtocolSupportNotifyFunc) }
ProtocolManager manages all protocol and protocol msg handler for all peers.
type ProtocolSupportNotifyFunc ¶
ProtocolSupportNotifyFunc is a function to notify peer protocol supporting or not.
type ReceiveStreamManager ¶
type ReceiveStreamManager interface { // Reset the manager. Reset() // SetPeerReceiveStreamMaxCount set the max count allowed. SetPeerReceiveStreamMaxCount(max int) // AddPeerReceiveStream append a receiving stream to manager. AddPeerReceiveStream(pid peer.ID, conn network.Conn, stream network.ReceiveStream) error // RemovePeerReceiveStream remove a receiving stream from manager. RemovePeerReceiveStream(pid peer.ID, conn network.Conn, stream network.ReceiveStream) error // GetCurrentPeerReceiveStreamCount return current count of receive streams // whose remote peer id is the given pid. GetCurrentPeerReceiveStreamCount(pid peer.ID) int // ClosePeerReceiveStreams will close all the receiving streams whose remote // peer id is the given pid and which created by the given connection. ClosePeerReceiveStreams(pid peer.ID, conn network.Conn) error }
ReceiveStreamManager manage all receive streams.
type SendStreamPool ¶
type SendStreamPool interface { io.Closer // Conn return the connection which send streams created by. Conn() network.Conn // InitStreams will open few send streams with the connection. InitStreams() error // BorrowStream get a sending stream from send stream queue in pool. // The stream borrowed should be return to this pool after sending data success, // or should be dropped by invoking DropStream method when errors found in sending data process. BorrowStream() (network.SendStream, error) // ReturnStream return a sending stream borrowed from this pool before. ReturnStream(network.SendStream) error // DropStream will close the sending stream then drop it. // This method should be invoked only when errors found. DropStream(network.SendStream) // MaxSize return cap of this pool. MaxSize() int // CurrentSize return current size of this pool. CurrentSize() int // IdleSize return current count of idle send stream. IdleSize() int }
SendStreamPool is a pool stores send streams.
type SendStreamPoolManager ¶
type SendStreamPoolManager interface { // Reset the manager. Reset() // AddPeerConnSendStreamPool append a stream pool for a connection of peer. AddPeerConnSendStreamPool(pid peer.ID, conn network.Conn, streamPool SendStreamPool) error // RemovePeerConnAndCloseSendStreamPool remove a connection of peer and close the stream pool for it. RemovePeerConnAndCloseSendStreamPool(pid peer.ID, conn network.Conn) error // GetPeerBestConnSendStreamPool return a stream pool for the best connection of peer. GetPeerBestConnSendStreamPool(pid peer.ID) SendStreamPool }
SendStreamPoolManager manage all send stream pools.
Click to show internal directories.
Click to hide internal directories.