Documentation ¶
Index ¶
- type List
- func (pl *List) Choose(ctx context.Context, req *transport.Request) (peer.Peer, func(error), error)
- func (pl *List) Introspect() introspection.ChooserStatus
- func (pl *List) IsRunning() bool
- func (pl *List) NotifyStatusChanged(pid peer.Identifier)
- func (pl *List) Start() error
- func (pl *List) Stop() error
- func (pl *List) Update(updates peer.ListUpdates) error
- type ListOption
- type PeerRing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is a PeerList which rotates which peers are to be selected in a circle
func New ¶
func New(transport peer.Transport, opts ...ListOption) *List
New creates a new round robin PeerList
func (*List) Introspect ¶
func (pl *List) Introspect() introspection.ChooserStatus
Introspect returns a ChooserStatus with a summary of the Peers.
func (*List) NotifyStatusChanged ¶
func (pl *List) NotifyStatusChanged(pid peer.Identifier)
NotifyStatusChanged when the peer's status changes
type ListOption ¶ added in v1.6.0
type ListOption func(*listConfig)
ListOption customizes the behavior of a roundrobin list.
func Capacity ¶ added in v1.6.0
func Capacity(capacity int) ListOption
Capacity specifies the default capacity of the underlying data structures for this list
Defaults to 10.
func StartupWait ¶ added in v1.6.0
func StartupWait(t time.Duration) ListOption
StartupWait specifies how long updates to the list will wait before the list has been started
Defaults to 5 seconds.
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