package picker
import "github.com/docker/swarmkit/picker"
Index ¶
- type Picker
- func NewPicker(r Remotes, initial ...string) *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
Types ¶
type Picker ¶
type Picker struct {
// contains filtered or unexported fields
}
Picker implements a grpc Picker
func NewPicker ¶
NewPicker returns a Picker
func (*Picker) Close ¶
Close closes all the Conn's owned by this 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) Reset ¶
Reset the current connection and force a reconnect to another address.
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.
Source Files ¶
- Version
- v1.12.0 (latest)
- Published
- Jul 26, 2016
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 3 hours ago –
Tools for package owners.