You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://github.com/resetius/miniraft-cpp)
6
6
7
+
## Table of Contents
8
+
-[Overview](#overview)
9
+
-[Key Features](#key-features)
10
+
-[Project Structure](#project-structure)
11
+
-[Getting Started](#getting-started)
12
+
-[Prerequisites](#prerequisites)
13
+
-[Building the Project](#building-the-project)
14
+
-[Running the Application](#running-the-application)
15
+
-[Example: State Machine (RSM) with Key-Value Store](#example-state-machine-rsm-with-key-value-store)
16
+
-[Server Mode](#server-mode)
17
+
-[Client Mode](#client-mode)
18
+
-[Media](#media)
19
+
20
+
---
21
+
7
22
## Overview
8
-
MiniRaft-CPP is an implementation of the Raft consensus algorithm using C++20. This project leverages the [coroio library](https://github.com/resetius/coroio) for efficient asynchronous I/O operations. It aims to provide a clear and efficient representation of the Raft protocol, ensuring consistency and reliability in distributed systems.
23
+
**MiniRaft-CPP** is a C++20 implementation of the Raft consensus algorithm.
24
+
It uses the [coroio library](https://github.com/resetius/coroio) for efficient asynchronous I/O and
25
+
aims to provide a straightforward reference for how Raft handles leader election,
26
+
log replication, and fault tolerance in a distributed system.
9
27
28
+
---
10
29
11
30
## Key Features
12
-
-**Leader Election**: Manages the election process for choosing a new leader in the cluster.
13
-
-**Log Replication**: Consistently replicates logs across all nodes in the cluster.
14
-
-**Safety**: Guarantees the integrity and durability of committed entries.
31
+
-**Leader Election** (supported)
32
+
-**Log Replication** (supported)
33
+
-**Persistence** (supported)
34
+
-**Snapshots** (not supported yet)
35
+
-**Membership Change** (not supported yet)
36
+
37
+
The project focuses on a clear, modular design that leverages C++20 coroutines to simplify asynchronous flows.
38
+
39
+
---
40
+
41
+
## Project Structure
42
+
43
+
-**`miniraft/`**
44
+
This directory contains the **MiniRaft library**, which implements all core components required for Raft consensus.
@@ -37,19 +91,19 @@ MiniRaft-CPP is an implementation of the Raft consensus algorithm using C++20. T
37
91
git submodule init
38
92
git submodule update
39
93
```
40
-
3. Navigate to the project directory:
94
+
3. Navigate to the project directory:
41
95
```
42
96
cd miniraft-cpp
43
97
```
44
-
4. Build the project using CMake:
98
+
4. Build the project using CMake:
45
99
```
46
100
cmake .
47
101
make
48
102
```
49
103
50
104
### Running the Application
51
105
52
-
This is a simple application designed to demonstrate log replication in the Raft consensus algorithm.
106
+
This is a simple application designed to demonstrate log replication in the Raft consensus algorithm.
53
107
54
108
To start the application, launch the servers with the following commands:
55
109
```
@@ -64,12 +118,11 @@ To interact with the system, run the client as follows:
64
118
```
65
119
The client expects an input string to be added to the distributed log. If the input string starts with an underscore (`_`), it should be followed by a number (e.g., `_ 3`). In this case, the client will attempt to read the log entry at the specified number.
66
120
121
+
### Example: State Machine (RSM) with Key-Value Store
67
122
68
-
### Distributed Key-Value Store Example
123
+
MiniRaft-CPP includes an example of a distributed Key-Value store implemented as a replicated state machine on top of Raft. The source code for this example resides in examples/kv.cpp
69
124
70
-
Additionally, there's an example implementing a distributed key-value (KV) store.
71
-
72
-
#### Starting KV Store Servers
125
+
#### Server Mode
73
126
74
127
To start the KV store servers, use:
75
128
```
@@ -78,7 +131,7 @@ To start the KV store servers, use:
@@ -90,6 +143,8 @@ The KV client expects commands as input:
90
143
3.`list` - Displays all key/value pairs in the store.
91
144
4.`del <key>` - Deletes a key from the store.
92
145
146
+
---
147
+
93
148
## Media
94
149
1.[Implementation of the Raft Consensus Algorithm Using C++20 Coroutines](https://dzone.com/articles/implementation-of-the-raft-consensus-algorithm-usi)
95
150
2.[Разработка сетевой библиотеки на C++20: интеграция асинхронности и алгоритма Raft (часть 1)](https://www.linux.org.ru/articles/development/17447126)
0 commit comments