Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckLeaderFunc ¶
CheckLeaderFunc is all that a special backend needs to implement. It can be used with the NewPoller function to return a polling implementation of the Detector interface. This function returns true or false for leadership when there are no errors. Returned error is reported and the status of the event will be set to `Unknown`.
func Always ¶
func Always(leader bool) CheckLeaderFunc
Always is a trivial implementation that asserts the current instance to always be the leader (or not)
type Detector ¶
type Detector interface { // Start starts leadership detection Start() (<-chan Leadership, error) // Receive allocates a channel for the caller to receive on. Messages are sent to all receivers. Receive() <-chan Leadership // Stop stops Stop() }
Detector is the interface for determining whether this instance is a leader
type Leadership ¶
Leadership is a struct that captures the leadership state, possibly error if exception occurs
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
Poller is the entity that polls for different backend / control planes to determine leadership
func NewPoller ¶
func NewPoller(pollInterval time.Duration, f CheckLeaderFunc) *Poller
NewPoller returns a detector implementation given the poll interval and function that polls
func (*Poller) Receive ¶
func (l *Poller) Receive() <-chan Leadership
Receive returns a channel to receive on. It broadcasts so that all channel receivers will get the same message.
func (*Poller) Start ¶
func (l *Poller) Start() (<-chan Leadership, error)
Start implements Detect.Start
type Store ¶
type Store interface { // UpdateLocation sets the leader to the given URL UpdateLocation(*url.URL) error // GetLocation returns the location of the current leader. It's possible that the leader location isn't // known despite no errors in querying. So the url can be nil GetLocation() (*url.URL, error) }
Store is an interface implemented by the environment that supports storing and retrieving the current leader location