Documentation ¶
Index ¶
- Constants
- Variables
- func Stream(conn net.Conn, remote plan.NetAddr, accept acceptFunc, handle MsgHandleFunc) (int, error)
- type BufferPool
- type ByteSlicePool
- type CollectiveEndpoint
- type ConnHandler
- type ConnType
- type Connection
- type ConnectionPool
- type Endpoint
- type Message
- type MsgHandleFunc
- type PeerToPeerEndpoint
- func (e *PeerToPeerEndpoint) Handle(conn net.Conn, remote plan.NetAddr, t ConnType) error
- func (e *PeerToPeerEndpoint) Request(a plan.Addr, version string, m Message) (bool, error)
- func (e *PeerToPeerEndpoint) Save(name string, buf *kb.Vector) error
- func (e *PeerToPeerEndpoint) SaveVersion(version, name string, buf *kb.Vector) error
- type Router
- type Server
Constants ¶
View Source
const ( // TODO: meaning of flags should be based on conn Type WaitRecvBuf uint32 = 1 << iota // The recevier should wait receive buffer IsResponse uint32 = 1 << iota // This is a response message for ConnPeerToPeer RequestFailed uint32 = 1 << iota // This is a response meesage for failed request )
View Source
const NoFlag uint32 = 0
Variables ¶
View Source
var ( GetBuf = defaultPool.GetBuf PutBuf = defaultPool.PutBuf )
View Source
var ErrInvalidConnectionType = errors.New("invalid connection type")
Functions ¶
Types ¶
type BufferPool ¶
type ByteSlicePool ¶
ByteSlicePool reuse byte slices: chunk size -> pool.
func (*ByteSlicePool) GetBuf ¶
func (p *ByteSlicePool) GetBuf(size uint32) []byte
GetBuf gets a chunk from reuse pool or creates a new one if reuse failed.
func (*ByteSlicePool) PutBuf ¶
func (p *ByteSlicePool) PutBuf(buf []byte)
PutBuf puts a chunk to reuse pool if it can be reused.
type CollectiveEndpoint ¶ added in v0.2.0
type CollectiveEndpoint struct {
// contains filtered or unexported fields
}
func NewCollectiveEndpoint ¶ added in v0.2.0
func NewCollectiveEndpoint() *CollectiveEndpoint
type ConnHandler ¶
type Connection ¶
type Connection interface { io.Closer Send(msgName string, m Message, flags uint32) error Read(msgName string, m Message) error }
Connection is a simplex logical connection from one peer to another
func NewPingConnection ¶
func NewPingConnection(remote, local plan.NetAddr) (Connection, error)
type ConnectionPool ¶
type Endpoint ¶
type Endpoint interface { Self() plan.PeerID ConnHandler }
type Message ¶
Message is the data transferred via channel
func (*Message) ReadFrom ¶
ReadFrom reads the message from a reader into new buffer. The message length is obtained from the reader and should be trusted.
type MsgHandleFunc ¶
type PeerToPeerEndpoint ¶ added in v0.2.0
type PeerToPeerEndpoint struct {
// contains filtered or unexported fields
}
func NewPeerToPeerEndpoint ¶ added in v0.2.0
func NewPeerToPeerEndpoint(router *Router) *PeerToPeerEndpoint
func (*PeerToPeerEndpoint) Save ¶ added in v0.2.0
func (e *PeerToPeerEndpoint) Save(name string, buf *kb.Vector) error
func (*PeerToPeerEndpoint) SaveVersion ¶ added in v0.2.0
func (e *PeerToPeerEndpoint) SaveVersion(version, name string, buf *kb.Vector) error
type Router ¶
type Router struct { Collective *CollectiveEndpoint // FIXME: move it out of Router P2P *PeerToPeerEndpoint // contains filtered or unexported fields }
func (*Router) ResetConnections ¶
Click to show internal directories.
Click to hide internal directories.