Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ibaryshnikov/raft-example
An example of using raft
https://github.com/ibaryshnikov/raft-example
Last synced: 6 days 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 (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-16T02:35:25.000Z (about 1 year ago)
- Last Synced: 2024-11-09T06:44:04.282Z (2 months ago)
- Language: Rust
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- 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"}}'
```