A generic raft library inspired etcd in C++

Overview

Overview

Raft is a protocol with which a cluster of nodes can maintain a replicated state machine. The state machine is kept in sync through the use of a replicated log. For more details on Raft, see "In Search of an Understandable Consensus Algorithm" (https://raft.github.io/raft.pdf) by Diego Ongaro and John Ousterhout.

Features

  • Leader election
  • Log replication
  • Log compaction
  • Membership changes
  • Leadership transfer extension

Build

make image
make build-dev

Run test

make test

How to build a kv store with eraft

  • example

Leader election

Leader election and log replication

Leader election

Membership changes

Membership changes

Code Style

https://google.github.io/styleguide/cppguide.html

Join Us on discussions

https://github.com/eraft-io/eraft/discussions

Scan QR code and follow our Zhihu account

知乎码

Our webiste https://eraft.cn

Project

Follow these projects to learn how to build a distributed key value system on Persistent memory device。

project 1 Implement a persistent memory kv engine based on pmemkv

project 2 Implement a concurrent web server based on epoll and multithreading technology

project 3 Implement a distributed consistency protocol : raft algorithm library

project 4 Implement a distributed kv storage system based on above project modules.

You might also like...
Generic single-file implementations of AVL tree in C and C++ suitable for deeply embedded systems
Generic single-file implementations of AVL tree in C and C++ suitable for deeply embedded systems

Cavl Generic single-file implementation of AVL tree suitable for deeply embedded systems. Simply copy cavl.h or cavl.hpp (depending on which language

A lightweight library of Behavior Trees Library in C++.

A lightweight behavior tree library in C++. NEWS! 💥 Thanks to Davide Faconti there is now a more sophisticated version of the library. The new versio

A simple C library for working with KD-Trees

kdtree Overview kdtree is a simple, easy to use C library for working with kd-trees. Kd-trees are an extension of binary search trees to k-dimensional

Linear Linked List Library

list.h Implementations for singly-linked and doubly-linked list functions. Basic Working Example #include stdio.h #include stdlib.h #include "list

C header library for typed lists (using macros and "template" C).

vector.h C header library for typed lists (using macros and "template" C). Essentially, this is a resizable array of elements of your choosing that is

Directed Acyclic Graph Execution Engine (DAGEE) is a C++ library that enables programmers to express computation and data movement, as task graphs that are scheduled concurrently and asynchronously on both CPUs and GPUs.

Directed Acyclic Graph Execution Engine (DAGEE) is a C++ library that enables programmers to express computation and data movement, as tasks in a graph structure, where edges represent task dependencies

nanoplan is a header-only C++11 library for search-based robot planning.
nanoplan is a header-only C++11 library for search-based robot planning.

nanoplan is a header-only C++11 library for search-based robot planning. The primary design goals are correctness, ease-of-use, and efficiency (in tha

libsais is a library for linear time suffix array and burrows wheeler transform construction based on induced sorting algorithm.

libsais libsais is a library for fast (see Benchmarks below) linear time suffix array and Burrows-Wheeler transform construction based on induced sort

An open source library for C

Eric O Meehan C Library Introduction Eric O Meehan's C Library is an open source collection of tools for the C programming language. The project is in

Comments
  • 关于初始化Raft节点的问题

    关于初始化Raft节点的问题

    您好: 在阅读代码时遇到一个疑问: raft.go代码初始化Raft节点时对该raft节点的日志进行了初始化:newraft.ReInitLog(),该初始化过程删除了所有日志, raft论文中logs日志时持久化保存的,为什么在代码中每次启动都要清空日志呢? 而且清空日志后,接下来执行了如下代码 newraft.matchIdx[peer.id], newraft.nextIdx[peer.id] = 0, int(LastLogIndex)+1 这样每次matchidx和nextidx都为0和1了? 不理解为什么每次启动程序就要删除所有日志,而不是加载已经持久化的日志呢?

    opened by sunzheng86 0
Releases(v1.0.3)
Owner
ERaftGroup
ERaftGroup
Library of generic and type safe containers in pure C language (C99 or C11) for a wide collection of container (comparable to the C++ STL).

M*LIB: Generic type-safe Container Library for C language Overview M*LIB (M star lib) is a C library enabling to use generic and type safe container i

PpHd 557 Dec 5, 2022
Easy to use, header only, macro generated, generic and type-safe Data Structures in C

C Macro Collections Easy to use, header only, macro generated, generic and type-safe Data Structures in C. Table of Contents Installation Contributing

Leonardo Vencovsky 330 Nov 27, 2022
A collecton of generic reference counted data structures, tools to create compatible C style classes, and demo applications

The Offbrand library is a collection of reference counted generic data structures written in C for C. The library includes bash scripts to assist in t

Tyler Heck 81 Nov 21, 2022
Functional, Type safe, Lazy abstractions for generic iterators in C

C-Iterplus Functional abstractions for working with iterators, as demonstrated in c-iterators. Finding the longest common prefix of an array of string

Chase 27 Oct 18, 2022
Generic parse tree, configurable lexer, `lemon` parser generator, wrapped for C++17 and Python 3.

This project augments the Lemon parser generator with a high-level parse tree interface, grammar action DSL, and an integrated, configurable lexer allowing the creation of an entire standalone, object-oriented parser from a single input grammar file. The entire parser is written in native C/C++, and the parser interface is made comfortably available to both C++ and Python3 applications.

Aubrey R. Jones 11 Jun 16, 2022
Generic Data Structures In C

Generic Data Structures In C Objective: ability to use data structures with full functionality on any data type type safety is absolutely critical, ma

null 5 May 4, 2022
Typesafe, Generic & Fastest Set Data structure implementation in C

Typesafe & Fast as fuck Set in C Key Features Extremely fast non-cryptographic hash algorithm XXHash Complete Typesafe APIs Double Hashing to avoid bo

Robus Gauli 4 Sep 6, 2021
Eggs.Variant is a C++11/14/17 generic, type-safe, discriminated union.

Eggs.Variant Introduction Eggs.Variant is a C++11/14/17 generic, type-safe, discriminated union. See the documentation at http://eggs-cpp.github.io/va

null 138 Dec 3, 2022
Typesafe, Generic & Extremely fast Dictionary in C 🚀

CDict.h Typesafe, Generic, and Extremely Fast Dictionary in C ?? Key Features Extremely fast non-cryptographic hash algorithm XXHash Complete Typesafe

Robus Gauli 18 Oct 5, 2022
Well Factored, Non-Recursive, General & Generic BSTs in ANSI C

This one set of files implements well factored/layered binary search trees (BSTs) with 5 balancing schemes (none, avl, red-black, L(k), and splay) and

null 2 Dec 7, 2021