https://github.com/ibaryshnikov/raft-example
An example of using raft
https://github.com/ibaryshnikov/raft-example
Last synced: about 1 month ago
JSON representation
An example of using raft
- Host: GitHub
- URL: https://github.com/ibaryshnikov/raft-example
- Owner: ibaryshnikov
- License: mit
- Created: 2023-12-13T20:47:33.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-16T02:35:25.000Z (almost 2 years ago)
- Last Synced: 2025-06-27T22:07:28.348Z (5 months ago)
- Language: Rust
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Raft example
Rebuilding an example from
[openraft](https://github.com/datafuselabs/openraft)
for learning purposes.
The original example is [raft-kv-memstore](https://github.com/datafuselabs/openraft/tree/main/examples/raft-kv-memstore).
## Usage
Start a node
```bash
cargo run -- --id 1 --http-addr 127.0.0.1:8081
```
Init leader
```bash
curl http://localhost:8081/init -H "Content-Type: application/json" -d '{}'
```
Add learner
```bash
curl http://localhost:8081/add-learner -H "Content-Type: application/json" -d '[2, "127.0.0.1:8082"]'
curl http://localhost:8081/add-learner -H "Content-Type: application/json" -d '[3, "127.0.0.1:8083"]'
```
Change membership
```bash
curl http://localhost:8081/change-membership -H "Content-Type: application/json" -d '[1, 2, 3]'
```
Metrics
```bash
curl http://localhost:8081/metrics
```
Read
```bash
curl http://localhost:8081/read -H "Content-Type: application/json" -d '"foo"'
```
Write
```bash
curl http://localhost:8081/write -H "Content-Type: application/json" -d '{"Set":{"key":"foo","value":"bar"}}'
```