Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EtcdElection ¶
type EtcdElection struct {
// contains filtered or unexported fields
}
func New ¶
func New(conf Config) (*EtcdElection, error)
Use leader election if you have several instances of a service running in production and you only want one of the service instances to preform a periodic task.
election, _ := election.New(election.Config{ Endpoints: []string{"http://192.168.99.100:2379"}, }) // Start the leader election and attempt to become leader election.Start() // Returns true if we are leader (thread safe) if election.IsLeader() { // Do periodic thing }
func NewFromClient ¶
func NewFromClient(conf Config, client etcd.Client) (*EtcdElection, error)
func (*EtcdElection) Concede ¶
func (s *EtcdElection) Concede() bool
Release leadership and return true if we own it, else do nothing and return false
func (*EtcdElection) IsLeader ¶
func (s *EtcdElection) IsLeader() bool
func (*EtcdElection) Start ¶
func (s *EtcdElection) Start()
func (*EtcdElection) Stop ¶
func (s *EtcdElection) Stop()
type LeaderElectionMock ¶
type LeaderElectionMock struct{}
func (*LeaderElectionMock) Concede ¶
func (s *LeaderElectionMock) Concede() bool
func (*LeaderElectionMock) IsLeader ¶
func (s *LeaderElectionMock) IsLeader() bool
func (*LeaderElectionMock) Start ¶
func (s *LeaderElectionMock) Start()
func (*LeaderElectionMock) Stop ¶
func (s *LeaderElectionMock) Stop()
Click to show internal directories.
Click to hide internal directories.