Documentation ¶
Index ¶
- type Binder
- type BoundChooser
- func (c *BoundChooser) Choose(ctx context.Context, treq *transport.Request) (peer peer.Peer, onFinish func(error), err error)
- func (c *BoundChooser) Introspect() introspection.ChooserStatus
- func (c *BoundChooser) IsRunning() bool
- func (c *BoundChooser) Start() error
- func (c *BoundChooser) Stop() error
- type Single
- func (s *Single) Choose(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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binder ¶ added in v1.7.0
Binder is a callback, provided to peer.Bind, that accepts a peer list and binds it to a peer provider for the duration of the returned lifecycle. The lifecycle that the binder returns should start and stop binding peers to the list. The binder must not call block on updating the list, because that will typically block until the peer list has started.
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 provider for the duration of its lifecycle.
func Bind ¶ added in v1.7.0
func Bind(chooserList peer.ChooserList, bind Binder) *BoundChooser
Bind couples a peer list with a peer provider. The peer provider must produce a binder that takes the peer list and returns a lifecycle for the duration of the binding.
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) 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 provider binding 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 provider binding.
func (*BoundChooser) Stop ¶ added in v1.7.0
func (c *BoundChooser) Stop() error
Stop stops the peer list and the peer provider binding.
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 x contains experimental components.
|
Package x contains experimental components. |