Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // GetLeader returns the current Leader stored in the KV store. If the Leader // is set, the returned ok flag will be true. If the Leader is not set, the // returned ok flag will be false. GetLeader() (id string, apiAddr string, addr string, ok bool, e error) // InitializeLeader sets the leader to the given details, but only if no leader // has already been set. This operation is a check-and-set type operation. If // initialization succeeds, ok is set to true, otherwise false. InitializeLeader(id, apiAddr, addr string) (bool, error) // SetLeader unconditionally sets the leader to the given details. SetLeader(id, apiAddr, addr string) error fmt.Stringer }
Client is the interface discovery clients must implement.
type Service ¶
type Service struct { RegisterInterval time.Duration ReportInterval time.Duration // contains filtered or unexported fields }
Service represents a Discovery Service instance.
func NewService ¶
NewService returns an instantiated Discovery Service.
func (*Service) Register ¶
Register registers this node with the discovery service. It will block until a) if the node is a voter, it registers itself, b) learns of another node it can use to join the cluster, or c) an unrecoverable error occurs.
func (*Service) StartReporting ¶
StartReporting reports the details of this node to the discovery service, if, and only if, this node is the leader. The service will report anytime a leadership change is detected. It also does it periodically to deal with any intermittent issues that caused Leadership information to go stale.
type Store ¶
type Store interface { // IsLeader returns whether this node is the Leader. IsLeader() bool // RegisterLeaderChange registers a channel that will be notified when // a leadership change occurs. RegisterLeaderChange(c chan<- struct{}) }
Store is the interface the consensus system must implement.
type Suffrage ¶
type Suffrage int
Suffrage is the type of suffrage -- voting or non-voting -- a node has.
func VoterSuffrage ¶
VoterSuffrage returns a Suffrage based on the given boolean.