peer

package
Version: v0.0.0-...-a69e935 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chooser

type Chooser interface {
	Start() error
	Stop() error
	Choose(context.Context, *transport.Request) (peer.Peer, func(error), error)
	IsRunning() bool
	UpdatePeer(urlString string) error
}

Chooser is the interface for a YARPC endpoint that can be updated dynamically. This is an implementation of go.uber.org/yarpc/peer/Chooser

func NewSimpleChooser

func NewSimpleChooser(role string, transport peer.Transport) Chooser

NewSimpleChooser creates a new Chooser, with no bells and whistles. Just a peer that can be updated manually. role is the string identifier for what this peer represents (mesos-master, hostmgr, etc)

func NewSmartChooser

func NewSmartChooser(
	cfg leader.ElectionConfig,
	scope tally.Scope,
	role string,
	transport peer.Transport) (Chooser, error)

NewSmartChooser creates a new SmartChooser with dynamic peer update support. It embeds a peer.chooser, but includes the ability to react to leadership changes in zookeeper and reconfigure the peer

type PeerChooser

type PeerChooser struct {
	sync.Mutex
	// contains filtered or unexported fields
}

PeerChooser is a yarpc-compatible Chooser, that periodically updates the peer url, by invoking the discover callback.

func NewPeerChooser

func NewPeerChooser(transport peer.Transport, discoverInterval time.Duration, f discoverFunc, r string) *PeerChooser

NewPeerChooser create a new Chooser for dynamically updating the remote peer. When called, discover will be called once to set initial peer, such that if the discover callback succeeds, it's guaranteed to have a peer.

func (*PeerChooser) Choose

func (c *PeerChooser) Choose(ctx context.Context, req *transport.Request) (peer.Peer, func(error), error)

Choose returns a peer

func (*PeerChooser) IsRunning

func (c *PeerChooser) IsRunning() bool

IsRunning returns true if a peer chooser is running

func (*PeerChooser) NotifyStatusChanged

func (c *PeerChooser) NotifyStatusChanged(id peer.Identifier)

NotifyStatusChanged receives notifications from the transport when the peer connects, disconnects, accepts a request, and so on.

func (*PeerChooser) Start

func (c *PeerChooser) Start() error

Start starts a peer chooser

func (*PeerChooser) Stop

func (c *PeerChooser) Stop() error

Stop stops a peer chooser

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL