Documentation ¶
Index ¶
- Variables
- type MeshAddr
- type Peer
- func (p *Peer) Close() error
- func (p *Peer) Gossip() (complete mesh.GossipData)
- func (p *Peer) LocalAddr() net.Addr
- func (p *Peer) OnGossip(buf []byte) (delta mesh.GossipData, err error)
- func (p *Peer) OnGossipBroadcast(_ mesh.PeerName, buf []byte) (received mesh.GossipData, err error)
- func (p *Peer) OnGossipUnicast(_ mesh.PeerName, buf []byte) error
- func (p *Peer) ReadFrom(b []byte) (n int, remote net.Addr, err error)
- func (p *Peer) Register(gossip mesh.Gossip)
- func (p *Peer) SetDeadline(time.Time) error
- func (p *Peer) SetReadDeadline(time.Time) error
- func (p *Peer) SetWriteDeadline(time.Time) error
- func (p *Peer) WriteTo(b []byte, dst net.Addr) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrShortRead is returned by ReadFrom when the // passed buffer is too small for the packet. ErrShortRead = errors.New("short read") // ErrPeerClosed is returned by ReadFrom and WriteTo // when the peer is closed during the operation. ErrPeerClosed = errors.New("peer closed") // ErrGossipNotRegistered is returned by Write to when attempting // to write before a mesh.Gossip has been registered in the peer. ErrGossipNotRegistered = errors.New("gossip not registered") // ErrNotMeshAddr is returned by WriteTo when attempting // to write to a non-mesh address. ErrNotMeshAddr = errors.New("not a mesh addr") // ErrNotSupported is returned by methods that are not supported. ErrNotSupported = errors.New("not supported") )
Functions ¶
This section is empty.
Types ¶
type MeshAddr ¶
type MeshAddr struct { mesh.PeerName // stable across invocations mesh.PeerUID // new with each invocation }
MeshAddr implements net.Addr for mesh peers.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer implements mesh.Gossiper and net.PacketConn.
func NewPeer ¶
NewPeer returns a Peer, which can be used as a net.PacketConn. Clients must Register a mesh.Gossip before calling ReadFrom or WriteTo. Clients should aggressively consume from ReadFrom.
func (*Peer) Gossip ¶
func (p *Peer) Gossip() (complete mesh.GossipData)
Gossip implements mesh.Gossiper.
func (*Peer) OnGossip ¶
func (p *Peer) OnGossip(buf []byte) (delta mesh.GossipData, err error)
OnGossip implements mesh.Gossiper. The buf is a single pkt.
func (*Peer) OnGossipBroadcast ¶
OnGossipBroadcast implements mesh.Gossiper. The buf is a single pkt
func (*Peer) OnGossipUnicast ¶
OnGossipUnicast implements mesh.Gossiper. The buf is a single pkt.
func (*Peer) ReadFrom ¶
ReadFrom implements net.PacketConn. Clients should consume from ReadFrom without blocking.
func (*Peer) Register ¶
Register injects the mesh.Gossip and enables full-duplex communication. Clients should consume from ReadFrom without blocking.
func (*Peer) SetDeadline ¶
SetDeadline implements net.PacketConn. SetDeadline is not supported.
func (*Peer) SetReadDeadline ¶
SetReadDeadline implements net.PacketConn. SetReadDeadline is not supported.
func (*Peer) SetWriteDeadline ¶
SetWriteDeadline implements net.PacketConn. SetWriteDeadline is not supported.