Easy to use Raft library to make your app distributed, highly available and fault-tolerant
An easy to use customizable library to make your Go application Distributed, Highly available, Fault Tolerant etc... using Hashicorp's Raft library which implements the Raft Consensus Algorithm.
Note: snapshots are not supported at the moment, will be handled at later point Note: at the moment the communication between nodes are insecure, I recommend to not expose that port
You can create a simple EasyRaft Node with local mDNS discovery, an in-memory Map service and MsgPack as serializer(this is the only one built-in at the moment)
import (
"github.com/ksrichard/easyraft"
"github.com/ksrichard/easyraft/discovery"
"github.com/ksrichard/easyraft/fsm"
"github.com/ksrichard/easyraft/serializer"
)
func main() {
raftPort := 5000
discoveryPort := 5001
dataDir := "s1"
node, err := easyraft.NewNode(
raftPort,
discoveryPort,
dataDir,
[]fsm.FSMService{fsm.NewInMemoryMapService()},
serializer.NewMsgPackSerializer(),
discovery.NewMDNSDiscovery(),
false,
)
if err != nil {
panic(err)
}
stoppedCh, err := node.Start()
if err != nil {
panic(err)
}
defer node.Stop()
}
Examples can be found in the examples directory
To regenerate gRPC code and install dependencies simply run make install