All Projects → markthethomas → raft-badger

markthethomas / raft-badger

Licence: MIT license
Badger-based backend for Hashicorp's raft package

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to raft-badger

raft-rocks
A simple database based on raft and rocksdb
Stars: ✭ 38 (+40.74%)
Mutual labels:  key-value, raft, consensus
Hraftd
A reference use of Hashicorp's Raft implementation
Stars: ✭ 732 (+2611.11%)
Mutual labels:  key-value, raft, consensus
Etcd
Distributed reliable key-value store for the most critical data of a distributed system
Stars: ✭ 38,238 (+141522.22%)
Mutual labels:  key-value, raft, consensus
Tikv
Distributed transactional key-value database, originally created to complement TiDB
Stars: ✭ 10,403 (+38429.63%)
Mutual labels:  key-value, raft, consensus
Verdi Raft
An implementation of the Raft distributed consensus protocol, verified in Coq using the Verdi framework
Stars: ✭ 143 (+429.63%)
Mutual labels:  key-value, raft, consensus
Zatt
Python implementation of the Raft algorithm for distributed consensus
Stars: ✭ 119 (+340.74%)
Mutual labels:  raft, consensus
Atomix
A reactive Java framework for building fault-tolerant distributed systems
Stars: ✭ 2,182 (+7981.48%)
Mutual labels:  raft, consensus
huffleraft
Replicated key-value store driven by the raft consensus protocol 🚵
Stars: ✭ 32 (+18.52%)
Mutual labels:  key-value, raft
Zookeeper
Apache ZooKeeper
Stars: ✭ 10,061 (+37162.96%)
Mutual labels:  key-value, consensus
Permazen
Language-Natural Persistence Layer for Java
Stars: ✭ 265 (+881.48%)
Mutual labels:  key-value, raft
Js
Gryadka is a minimalistic master-master replicated consistent key-value storage based on the CASPaxos protocol
Stars: ✭ 304 (+1025.93%)
Mutual labels:  key-value, consensus
Bifrost
Pure rust building block for distributed systems
Stars: ✭ 118 (+337.04%)
Mutual labels:  raft, consensus
X0
Xzero HTTP Application Server
Stars: ✭ 111 (+311.11%)
Mutual labels:  raft, consensus
Sofa Jraft
A production-grade java implementation of RAFT consensus algorithm.
Stars: ✭ 2,618 (+9596.3%)
Mutual labels:  raft, consensus
Trepang
Trepang is an implementation of Raft Algorithm in Go
Stars: ✭ 111 (+311.11%)
Mutual labels:  raft, consensus
Yaraft
Yet Another RAFT implementation
Stars: ✭ 109 (+303.7%)
Mutual labels:  raft, consensus
Consensus Yaraft
consensus-yaraft is a library for distributed, strong consistent, highly replicated log storage. It's based on yaraft, which is an implementation of the Raft protocol.
Stars: ✭ 30 (+11.11%)
Mutual labels:  raft, consensus
Rqlite
The lightweight, distributed relational database built on SQLite
Stars: ✭ 9,147 (+33777.78%)
Mutual labels:  raft, consensus
Godown
Distributed, fault-tolerant key-value storage written in go.
Stars: ✭ 352 (+1203.7%)
Mutual labels:  key-value, raft
Elasticell
Elastic Key-Value Storage With Strong Consistency and Reliability
Stars: ✭ 453 (+1577.78%)
Mutual labels:  key-value, raft

raft-badger

CircleCI Go Report Card Maintainability codecov.io Code Coverage HitCount GoDoc

Raft + Badger backend plugin

This repository provides a storage backend for the excellent raft package from Hashicorp. Raft is a distributed consensus protocol. Distributed consensus has many practical applications, ranging from fault-tolerant databases to clock synchronization to things like Google's PageRank.

This package exports the BadgerStore, which is an implementation of both a LogStore and StableStore (interfaces used by the raft package for reading/writing logs as part of its consensus protocol).

installation

go get -u github.com/markthethomas/raft-badger

usage

Create a new BadgerStore and pass it to Raft when setting up.

//...
var logStore raft.LogStore
var stableStore raft.StableStore
myPath  := filepath.Join(s.RaftDir) // replace this with what you're actually using
badgerDB, err := raftbadgerdb.NewBadgerStore(myPath)
if err != nil {
  return fmt.Errorf("error creating new badger store: %s", err)
}
logStore = badgerDB
stableStore = badgerDB

r, err := raft.NewRaft(config, (*fsm)(s), logStore, stableStore, snapshots, transport)
//...

developing

To run tests, run:

go test -cover -coverprofile=coverage.out .

To view coverage, run:

go tool cover -html=coverage.out

To run the benchmark, run:

go test -race -bench .

motivation

This package is meant to be used with the raft package from Hashicorb. This package borrows heavily from the excellent raft-boltdb package, also from Hashicorp. I wanted to learn about Badger and similar tools and needed to use Raft + a durable backend.

misc.

  • raft-badger uses prefix keys to "bucket" logs and config, avoiding the need for multiple badger database files for each type of k/v raft sets
  • encodes/decodes the raft Log types using Go's gob for efficient encoding/decoding of keys See more at https://blog.golang.org/gobs-of-data.
  • images used are from the raft website and the badger repository, respectively
  • thanks to the authors of the excellent raft-boltdb package for providing patterns to follow in satisfying the requisite raft interfaces 🙌
  • curious to learn more about the raft protocol? check out the raft website. There's also a beginner's guide at Free Code Camp

todo

  • support custom badger options
  • explore other encodings besides gob
  • add more examples of use with raft
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].