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
type ElectConfig ¶
type ElectConfig struct { // Timeout for connecting to peers ConnectTimeout uint // List of peers in the network Peers []Node // Node information Node Node // State callbacks CallBacks *StateCallBacks // Timeout for callbacks 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.