Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultTimeout = 5 * time.Second DefaultPort = 12379 DefaultServer = "127.0.0.1" )
Client defaults
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client describes a ETCD configuration client
func (*Client) NewElection ¶
func (client *Client) NewElection(path string) MasterElection
NewElection creates a new ETCD master elector
type MasterElection ¶
type MasterElection interface { Start() StartAndWait() Stop() IsMaster() bool AddEventListener(listener MasterElectionListener) TTL() time.Duration }
MasterElection describes the master election mechanism
type MasterElectionListener ¶
type MasterElectionListener interface { OnStartAsMaster() OnStartAsSlave() OnSwitchToMaster() OnSwitchToSlave() }
MasterElectionListener describes the multi election mechanism
type MasterElectionService ¶
type MasterElectionService interface {
NewElection(key string) MasterElection
}
MasterElectionService describes the election service mechanism
type MasterElector ¶
type MasterElector struct { insanelock.RWMutex EtcdKeyAPI etcd.KeysAPI HolderID string // contains filtered or unexported fields }
MasterElector describes an ETCD master elector
func NewMasterElector ¶
func NewMasterElector(etcdClient *Client, path string) *MasterElector
NewMasterElector creates a new ETCD master elector
func (*MasterElector) AddEventListener ¶
func (le *MasterElector) AddEventListener(listener MasterElectionListener)
AddEventListener registers a new listener
func (*MasterElector) IsMaster ¶
func (le *MasterElector) IsMaster() bool
IsMaster returns true if the current instance is master
func (*MasterElector) StartAndWait ¶
func (le *MasterElector) StartAndWait()
StartAndWait starts the election mechanism and wait for the first election before returning
Click to show internal directories.
Click to hide internal directories.