Documentation ¶
Index ¶
- type PeerRing
- type RoundRobin
- func (pl *RoundRobin) Add(pid peer.Identifier) error
- func (pl *RoundRobin) ChoosePeer(ctx context.Context, req *transport.Request) (peer.Peer, error)
- func (pl *RoundRobin) NotifyStatusChanged(pid peer.Identifier)
- func (pl *RoundRobin) Remove(pid peer.Identifier) error
- func (pl *RoundRobin) Start() error
- func (pl *RoundRobin) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PeerRing ¶
type PeerRing struct {
// contains filtered or unexported fields
}
PeerRing provides a safe way to interact (Add/Remove/Get) with a potentially changing list of peer objects PeerRing is NOT Thread-safe, make sure to only call PeerRing functions with a lock
func NewPeerRing ¶
NewPeerRing creates a new PeerRing with an initial capacity
func (*PeerRing) Add ¶
Add a peer.Peer to the end of the PeerRing, if the ring is empty it initializes the nextNode marker
func (*PeerRing) GetPeer ¶
func (pr *PeerRing) GetPeer(pid peer.Identifier) peer.Peer
GetPeer returns the Peer from the Ring or Nil
func (*PeerRing) Next ¶
Next returns the next peer in the ring, or nil if there is no peer in the ring after it has the next peer, it increments the nextPeer marker in the ring
type RoundRobin ¶
type RoundRobin struct {
// contains filtered or unexported fields
}
RoundRobin is a PeerList which rotates which peers are to be selected in a circle
func NewRoundRobin ¶
func NewRoundRobin(peerIDs []peer.Identifier, agent peer.Agent) (*RoundRobin, error)
NewRoundRobin creates a new round robin PeerList using
func (*RoundRobin) Add ¶
func (pl *RoundRobin) Add(pid peer.Identifier) error
Add a peer identifier to the round robin
func (*RoundRobin) ChoosePeer ¶
ChoosePeer selects the next available peer in the round robin
func (*RoundRobin) NotifyStatusChanged ¶
func (pl *RoundRobin) NotifyStatusChanged(pid peer.Identifier)
NotifyStatusChanged when the peer's status changes
func (*RoundRobin) Remove ¶
func (pl *RoundRobin) Remove(pid peer.Identifier) error
Remove a peer identifier from the round robin
func (*RoundRobin) Start ¶
func (pl *RoundRobin) Start() error
Start notifies the RoundRobin that requests will start coming
func (*RoundRobin) Stop ¶
func (pl *RoundRobin) Stop() error
Stop notifies the RoundRobin that requests will stop coming