Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ElectionInfo ¶
type ElectionInfo struct { // LeaderAddress is the ip address of leader LeaderAddress string // IsLeader returns true if current node is leader IsLeader bool }
ElectionInfo is the response for http election service
type LeaderElection ¶
type LeaderElection interface { // Campaign run leader election loop Campaign() // GetLeaderInfo get leader info, return peer address GetLeaderInfo() string // IsLeader return true when this instance is leader IsLeader() bool // GetElectionInfo get info of election GetElectionInfo() (ElectionInfo, error) }
LeaderElection is responsible for run leader election and handle state when leader status changed
func NewLeaderElection ¶
func NewLeaderElection(backend b.Backend, metricCli metrics.Metrics, onStartedLeading func(context.Context), onStoppedLeading func()) LeaderElection
NewLeaderElection returns a LeaderElection based on resourcelock of backend.Backend
type Stub ¶
type Stub struct {
ElectionInfo
}
Stub is an implement of LeaderElection for test
func (*Stub) GetElectionInfo ¶
func (s *Stub) GetElectionInfo() (ElectionInfo, error)
GetElectionInfo implements LeaderElection interface
func (*Stub) GetLeaderInfo ¶
GetLeaderInfo implements LeaderElection interface
Click to show internal directories.
Click to hide internal directories.