nats-io / Graft
Licence: apache-2.0
A RAFT Election implementation in Go.
Stars: ✭ 118
Programming Languages
go
31211 projects - #10 most used programming language
Graft
A RAFT Election implementation in Go. More information on RAFT can be found in this research paper and this video.
Overview
RAFT is a consensus based algorithm that produces consistent state through replicated logs and leader elections.
Example usage of the election algorithm is to produce guaranteed leaders for N-wise scalability and elimination of SPOF (Single Point of Failure) within a system.
Example Usage
ci := graft.ClusterInfo{Name: "health_manager", Size: 3}
rpc, err := graft.NewNatsRpc(&nats.DefaultOptions)
errChan := make(chan error)
stateChangeChan := make(chan StateChange)
handler := graft.NewChanHandler(stateChangeChan, errChan)
node, err := graft.New(ci, handler, rpc, "/tmp/graft.log");
// ...
if node.State() == graft.LEADER {
// Process as a LEADER
}
select {
case sc := <- stateChangeChan:
// Process a state change
case err := <- errChan:
// Process an error, log etc.
}
License
Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].