Documentation ¶
Index ¶
- Constants
- func NewMasterSlave(stfile string, rsIp, rsPort, rsUnixPath string, ...) *msElector
- func NewSinglePoint(stfile, rsIp, rsPort, rsUnixPath string) *spElector
- func WithLeaderTimeout(timeout uint) electorOption
- func WithPingPeriod(period uint) electorOption
- func WithProtectionPeriod(period uint) electorOption
- func WithRetryPeriod(retryPeriod uint) electorOption
- type ClusterElector
- type Elector
- type ElectorInfo
- type Role
Constants ¶
View Source
const ( // RoleCandidate represents a candidate RoleCandidate = Role(0) // RoleFollower represents a follower RoleFollower = Role(1) // RoleLeader represents a leader RoleLeader = Role(2) // RoleUnstable represents an unstable elector, which indicate that the user who request // the elector's role may retry later. // NOTE: the RoleUnstable is NOT a role of elector-state-machine, it is only used // for replying user requests when the leader is in leaderBootstrapState state. RoleUnstable = Role(5) )
Variables ¶
This section is empty.
Functions ¶
func NewMasterSlave ¶
func NewMasterSlave( stfile string, rsIp, rsPort, rsUnixPath string, localEleIp, localElePort string, remoteEleIp, remoteElePort string, opts ...electorOption, ) *msElector
NewmsElector is the constructor of msElector
func NewSinglePoint ¶
func NewSinglePoint(stfile, rsIp, rsPort, rsUnixPath string) *spElector
NewSinglePoint is the constructor of spElector
func WithLeaderTimeout ¶
func WithLeaderTimeout(timeout uint) electorOption
WithLeaderTimeout set how long we thought the leader is unreachable
func WithPingPeriod ¶
func WithPingPeriod(period uint) electorOption
WithPingPeriod set the period among sending ping
func WithProtectionPeriod ¶
func WithProtectionPeriod(period uint) electorOption
WithProtectionPeriod set the period of leader protection
func WithRetryPeriod ¶
func WithRetryPeriod(retryPeriod uint) electorOption
WithRetryPeriod set the retry period for re-connection
Types ¶
type ClusterElector ¶
type ClusterElector struct {
// contains filtered or unexported fields
}
ClusterElector is used in cluster mode
func NewClusterElector ¶
func NewClusterElector(path, rsIp, rsPort, rsUnixPath string, zkHost []string, zkLeaderDir string, opts ...electorOption) *ClusterElector
NewClusterElector is the constructor of ClusterElector
func (*ClusterElector) Role ¶
func (e *ClusterElector) Role() Role
Role return the role of the elector
type Elector ¶
type Elector interface { Start() error Stop() error Info() ElectorInfo Abdicate() Promote() }
Elector is the interface of all kinds of electors
type ElectorInfo ¶
type ElectorInfo struct {
// contains filtered or unexported fields
}
ElectorInfo represent basic info for a elector
func (ElectorInfo) String ¶
func (ei ElectorInfo) String() string
Click to show internal directories.
Click to hide internal directories.