Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Elect ¶
type Elect struct {
// contains filtered or unexported fields
}
Elect contains information about an election
func NewElect ¶
func NewElect(cfg *ElectConfig, logger log.Logger) (*Elect, error)
NewElect creates a new Elect instance
func (*Elect) ClusterState ¶ added in v1.0.1
func (e *Elect) ClusterState() (*model.ClusterState, error)
ClusterState returns current cluster state
func (*Elect) CurrentState ¶
CurrentState returns current node state
type ElectConfig ¶
type ElectConfig struct { // Timeout for heartbeat messages, in milliseconds HeartBeatInterval uint // Timeout for election messages, in milliseconds ElectTimeout uint // Timeout for connecting to peers, in seconds ConnectTimeout uint // List of peers in the network Peers []Node // Node represents the information of this node Node Node // State callbacks CallBacks *StateCallBacks // Timeout for callbacks, in seconds CallBackTimeout int }
ElectConfig is a struct that represents the configuration for an election.
type Node ¶
type Node struct { // ID of the node ID string // Address of the node Address string // NoVote indicates whether the node is able to vote NoVote bool // Tags associated with the node Tags map[string]string }
Node is a struct that represents an elect node
type StateCallBacks ¶
type StateCallBacks struct { // EnterLeader is a callback function to be called when entering the leader state EnterLeader StateHandler // LeaveLeader is a callback function to be called when leaving the leader state LeaveLeader StateHandler // EnterFollower is a callback function to be called when entering the follower state EnterFollower StateHandler // LeaveFollower is a callback function to be called when leaving the follower state LeaveFollower StateHandler // EnterCandidate is a callback function to be called when entering the candidate state EnterCandidate StateHandler // LeaveCandidate is a callback function to be called when leaving the candidate state LeaveCandidate StateHandler }
StateCallBacks is a struct to hold state callbacks
type StateHandler ¶
type StateHandler func(ctx context.Context, st model.StateTransition) error
Click to show internal directories.
Click to hide internal directories.