Documentation ¶
Index ¶
- type Picker
- func (p *Picker) Close() error
- func (p *Picker) Init(cc *grpc.ClientConn) error
- func (p *Picker) Pick(ctx context.Context) (transport.ClientTransport, error)
- func (p *Picker) PickAddr() (string, error)
- func (p *Picker) Reset() error
- func (p *Picker) State() (grpc.ConnectivityState, error)
- func (p *Picker) WaitForStateChange(ctx context.Context, sourceState grpc.ConnectivityState) (grpc.ConnectivityState, error)
- type Remotes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Picker ¶
type Picker struct {
// contains filtered or unexported fields
}
Picker implements a grpc Picker
func (*Picker) Init ¶
func (p *Picker) Init(cc *grpc.ClientConn) error
Init does initial processing for the Picker, e.g., initiate some connections.
func (*Picker) Pick ¶
Pick blocks until either a transport.ClientTransport is ready for the upcoming RPC or some error happens.
func (*Picker) PickAddr ¶
PickAddr picks a peer address for connecting. This will be called repeated for connecting/reconnecting.
func (*Picker) State ¶
func (p *Picker) State() (grpc.ConnectivityState, error)
State returns the connectivity state of the underlying connections.
func (*Picker) WaitForStateChange ¶
func (p *Picker) WaitForStateChange(ctx context.Context, sourceState grpc.ConnectivityState) (grpc.ConnectivityState, error)
WaitForStateChange blocks until the state changes to something other than the sourceState. It returns the new state or error.
type Remotes ¶
type Remotes interface { // Weight returns the remotes with their current weights. Weights() map[api.Peer]int // Select a remote from the set of available remotes with optionally // excluding ID or address. Select(...string) (api.Peer, error) // Observe records an experience with a particular remote. A positive weight // indicates a good experience and a negative weight a bad experience. // // The observation will be used to calculate a moving weight, which is // implementation dependent. This method will be called such that repeated // observations of the same master in each session request are favored. Observe(peer api.Peer, weight int) // ObserveIfExists records an experience with a particular remote if when a // remote exists. ObserveIfExists(peer api.Peer, weight int) // Remove the remote from the list completely. Remove(addrs ...api.Peer) }
Remotes keeps track of remote addresses by weight, informed by observations.
func NewRemotes ¶
NewRemotes returns a Remotes instance with the provided set of addresses. Entries provided are heavily weighted initially.