Documentation ¶
Index ¶
- func Identify(peer string) peer.Identifier
- type Peer
- func (p *Peer) EndRequest()
- func (p *Peer) HostPort() string
- func (p *Peer) NotifyStatusChanged()
- func (p *Peer) NumSubscribers() int
- func (p *Peer) SetStatus(status peer.ConnectionStatus)
- func (p *Peer) StartRequest()
- func (p *Peer) Status() peer.Status
- func (p *Peer) Subscribe(sub peer.Subscriber)
- func (p *Peer) Transport() peer.Transport
- func (p *Peer) Unsubscribe(sub peer.Subscriber) error
- type PeerIdentifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Identify ¶
func Identify(peer string) peer.Identifier
Identify coerces a string to a PeerIdentifier
Types ¶
type Peer ¶
type Peer struct { PeerIdentifier // contains filtered or unexported fields }
Peer keeps a subscriber to send status updates to it, and the peer.Transport that created it
func NewPeer ¶
func NewPeer(pid PeerIdentifier, transport peer.Transport) *Peer
NewPeer creates a new abstractpeer.Peer from a abstractpeer.PeerIdentifier, peer.Transport, and peer.Subscriber
func (*Peer) EndRequest ¶
func (p *Peer) EndRequest()
EndRequest should be run after a request has finished.
func (*Peer) HostPort ¶
HostPort surfaces the HostPort in this function, if you want to access the hostport directly (for a downstream call) You need to cast the Peer to a *abstractpeer.Peer and run this function
func (*Peer) NotifyStatusChanged ¶
func (p *Peer) NotifyStatusChanged()
NotifyStatusChanged broadcasts a status change notification to all subscribers.
func (*Peer) NumSubscribers ¶
NumSubscribers returns the number of subscriptions attached to the peer
func (*Peer) SetStatus ¶
func (p *Peer) SetStatus(status peer.ConnectionStatus)
SetStatus sets the status of the Peer (to be used by the peer.Transport)
func (*Peer) StartRequest ¶
func (p *Peer) StartRequest()
StartRequest runs at the beginning of a request.
func (*Peer) Subscribe ¶
func (p *Peer) Subscribe(sub peer.Subscriber)
Subscribe adds a subscriber to the peer's subscriber map
func (*Peer) Transport ¶
Transport returns the peer.Transport that is in charge of this abstractpeer.Peer (and should be the one to handle requests)
func (*Peer) Unsubscribe ¶
func (p *Peer) Unsubscribe(sub peer.Subscriber) error
Unsubscribe removes a subscriber from the peer's subscriber map
type PeerIdentifier ¶
type PeerIdentifier string
PeerIdentifier uniquely references a host:port combination using a common interface
func (PeerIdentifier) Identifier ¶
func (p PeerIdentifier) Identifier() string
Identifier generates a (should be) unique identifier for this PeerIdentifier (to use in maps, etc)