Documentation
¶
Index ¶
Constants ¶
View Source
const ( RetryCampaignInterval = 5 * time.Second DefaultEtcdSessionTTLSeconds = 5 )
View Source
const (
LeaderWatcherInterval = 5 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ElectLeaderStatus ¶
type IMonitor ¶
type IMonitor interface {
RunElectLeader(ctx context.Context, ch chan *ElectLeaderStatus, path string)
}
type LeaderInfo ¶
type LeaderInfo struct {
NodeID string
}
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
func (*Monitor) GetLeader ¶
func (m *Monitor) GetLeader(ctx context.Context, election *concurrency.Election) (*LeaderInfo, error)
GetLeader fetches the value that is set by the leader.
func (*Monitor) RunElectLeader ¶
func (m *Monitor) RunElectLeader(ctx context.Context, ch chan *ElectLeaderStatus, path string) error
RunElectLeader is the main entrypoint for launching a monitoring instance. It will elect and launch a leader + continue monitoring for leadership changes.
Flow:
1. In a loop, Campaign() to become leader 2. Campaign() blocks until leader is acquired 3. When leader is acquired:
- Launch runLeader
- Launch runLeaderWatcher
- runLeaderWatcher verifies that we are still leader AND monitors shutdown ctx. If either has changed/triggered: it will shutdown RunLeader and itself.
- runLeader has watches for incoming alerts/etc.
Etcd layout ¶
TBD
Click to show internal directories.
Click to hide internal directories.