Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nats-io/graft
A RAFT Election implementation in Go.
https://github.com/nats-io/graft
Last synced: 3 months ago
JSON representation
A RAFT Election implementation in Go.
- Host: GitHub
- URL: https://github.com/nats-io/graft
- Owner: nats-io
- License: apache-2.0
- Created: 2013-07-17T15:45:46.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2024-04-02T19:29:49.000Z (7 months ago)
- Last Synced: 2024-06-18T14:07:49.939Z (5 months ago)
- Language: Go
- Size: 120 KB
- Stars: 175
- Watchers: 38
- Forks: 37
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome - Graft - Raft algorithm (Open source library / Algorithm)
README
Graft
=====A RAFT Election implementation in Go. More information on RAFT can be found in this [research paper](https://ramcloud.stanford.edu/wiki/download/attachments/11370504/raft.pdf
) and this [video](http://www.youtube.com/watch?v=YbZ3zDzDnrw&list=WL20FE97C942825E1E).[![License Apache 2](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Build Status](https://travis-ci.com/nats-io/graft.svg?branch=main)](https://app.travis-ci.com/github/nats-io/graft)
[![Coverage Status](https://coveralls.io/repos/github/nats-io/graft/badge.svg)](https://coveralls.io/github/nats-io/graft)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
```go
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.