Documentation ¶
Overview ¶
Package peer contains components for managing peers.
The `go.uber.org/yarpc/api/peer` package provides the corresponding interfaces that these components implement.
The HTTP and TChannel `NewOutbound` methods accept a `peer.Chooser`. To bind an outbound to a single peer, pass a `peer.NewSingle(id)`.
To bind an outbound to multiple peers, you will need a peer list, like `roundrobin` (to pick the least recently chosen peer) or `peerheap` (to choose the peer with the fewest pending requests). Assuming you choose `peerheap`, to bind multiple peers you would pass `peer.Bind(peerheap.New(transport), peer.BindPeers(ids))`.
Each transport can define its own domain of peer identifiers, but most will use a host:port address for the remote listening socket. The `"go.uber.org/yarpc/peer/hostport"` package implements the common `hostport.PeerIdentifier` and `hostport.Peer`.
Index ¶
- func BindPeers(ids []peer.Identifier) peer.Binder
- type BoundChooser
- func (c *BoundChooser) Choose(ctx context.Context, treq *transport.Request) (peer peer.Peer, onFinish func(error), err error)
- func (c *BoundChooser) ChooserList() peer.ChooserList
- func (c *BoundChooser) Introspect() introspection.ChooserStatus
- func (c *BoundChooser) IsRunning() bool
- func (c *BoundChooser) Start() error
- func (c *BoundChooser) Stop() error
- func (c *BoundChooser) Updater() transport.Lifecycle
- type PeersUpdater
- type Single
- func (s *Single) Choose(ctx context.Context, _ *transport.Request) (peer.Peer, func(error), error)
- func (s *Single) Introspect() introspection.ChooserStatus
- func (s *Single) IsRunning() bool
- func (s *Single) NotifyStatusChanged(_ peer.Identifier)
- func (s *Single) Start() error
- func (s *Single) Stop() error
- func (s *Single) Transport() peer.Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BoundChooser ¶ added in v1.7.0
type BoundChooser struct {
// contains filtered or unexported fields
}
BoundChooser is a peer chooser that couples a peer list and a peer list updater for the duration of its lifecycle.
func Bind ¶ added in v1.7.0
func Bind(chooserList peer.ChooserList, bind peer.Binder) *BoundChooser
Bind couples a peer list with a peer list updater. Bind accepts a peer list and passes that peer list to a binder. The binder must return a peer list updater bound to the peer list. The peer list updater must implement Lifecycle so the bound peer list can start and stop updates.
func (*BoundChooser) Choose ¶ added in v1.7.0
func (c *BoundChooser) Choose(ctx context.Context, treq *transport.Request) (peer peer.Peer, onFinish func(error), err error)
Choose returns a peer from the bound peer list.
func (*BoundChooser) ChooserList ¶ added in v1.8.0
func (c *BoundChooser) ChooserList() peer.ChooserList
ChooserList returns the bound peer list.
func (*BoundChooser) Introspect ¶ added in v1.7.0
func (c *BoundChooser) Introspect() introspection.ChooserStatus
Introspect introspects the bound chooser.
func (*BoundChooser) IsRunning ¶ added in v1.7.0
func (c *BoundChooser) IsRunning() bool
IsRunning returns whether the peer list and its peer list updater are both running, regardless of whether they should be running according to the bound chooser's lifecycle.
func (*BoundChooser) Start ¶ added in v1.7.0
func (c *BoundChooser) Start() error
Start starts the peer list and the peer list updater.
func (*BoundChooser) Stop ¶ added in v1.7.0
func (c *BoundChooser) Stop() error
Stop stops the peer list and the peer list updater.
func (*BoundChooser) Updater ¶ added in v1.8.0
func (c *BoundChooser) Updater() transport.Lifecycle
Updater returns the bound peer list updater.
type PeersUpdater ¶ added in v1.8.0
type PeersUpdater struct {
// contains filtered or unexported fields
}
PeersUpdater binds a fixed list of peers to a peer list.
func (*PeersUpdater) IsRunning ¶ added in v1.8.0
func (s *PeersUpdater) IsRunning() bool
IsRunning returns whether the peers have been added and not removed.
func (*PeersUpdater) Start ¶ added in v1.8.0
func (s *PeersUpdater) Start() error
Start adds a list of fixed peers to a peer list.
func (*PeersUpdater) Stop ¶ added in v1.8.0
func (s *PeersUpdater) Stop() error
Stop removes a list of fixed peers from a peer list.
type Single ¶ added in v1.0.0
type Single struct {
// contains filtered or unexported fields
}
Single implements the Chooser interface for a single peer
func NewSingle ¶ added in v1.0.0
func NewSingle(pid peer.Identifier, transport peer.Transport) *Single
NewSingle creates a static Chooser with a single Peer
func (*Single) Introspect ¶ added in v1.0.0
func (s *Single) Introspect() introspection.ChooserStatus
Introspect returns a ChooserStatus with a single PeerStatus.
func (*Single) NotifyStatusChanged ¶ added in v1.0.0
func (s *Single) NotifyStatusChanged(_ peer.Identifier)
NotifyStatusChanged receives notifications from the transport when the peer connects, disconnects, accepts a request, and so on.
Directories ¶
Path | Synopsis |
---|---|
Package peerlist is deprecated in favor of `go.uber.org/yarpc/peer/peerlist/v2` which can additionally convey peer list identifiers to the peerlist.Implementation without a wrapper type, allowing a peer list updater to communicate shard information for example.
|
Package peerlist is deprecated in favor of `go.uber.org/yarpc/peer/peerlist/v2` which can additionally convey peer list identifiers to the peerlist.Implementation without a wrapper type, allowing a peer list updater to communicate shard information for example. |
v2
Package peerlist provides a utility for managing peer availability with a separate implementation of peer selection from just among available peers.
|
Package peerlist provides a utility for managing peer availability with a separate implementation of peer selection from just among available peers. |
Package pendingheap provides an implementation of a peer list that sends traffic to the peer with the fewest pending requests, but degenerates to round robin when all peers have equal pending requests, using a heap.
|
Package pendingheap provides an implementation of a peer list that sends traffic to the peer with the fewest pending requests, but degenerates to round robin when all peers have equal pending requests, using a heap. |
Package x contains experimental components.
|
Package x contains experimental components. |