Goelect is an open-source, self-contained Golang library designed to facilitate leader election within a distributed system.
Goelect is an open-source, self-contained Golang library designed to facilitate leader election within a distributed system.
Goelect is an open-source Go (Golang) library for leader election. It is heavily influenced by the election component of the Raft implementation. For more details, you can refer to Raft Wiki.
// ElectConfig is a struct that represents the configuration for an election.
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
}examples/onenode/node.go is a great example of using this goelect package.
Create an Elect instance:
…Start the Elect:
err = e.Run()This is everything we need to do :)
No open issues yet, or sync has not completed.