https://github.com/ldmtam/raft-auto-increment
Distributed, fault-tolerant, persistent, auto-increment ID generation service with Raft consensus
https://github.com/ldmtam/raft-auto-increment
autoincrement badger bitcask distributed-systems fault-tolerance golang raft-consensus
Last synced: 5 months ago
JSON representation
Distributed, fault-tolerant, persistent, auto-increment ID generation service with Raft consensus
- Host: GitHub
- URL: https://github.com/ldmtam/raft-auto-increment
- Owner: ldmtam
- Created: 2019-12-28T06:32:17.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-01-21T09:24:49.000Z (over 1 year ago)
- Last Synced: 2025-03-30T01:51:47.554Z (6 months ago)
- Topics: autoincrement, badger, bitcask, distributed-systems, fault-tolerance, golang, raft-consensus
- Language: Go
- Homepage:
- Size: 85 KB
- Stars: 25
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Raft Auto Increment
Distributed, fault-tolerant, persistent, auto-increment ID generation service with Raft consensus.Support both `REST API` and `gRPC` protocol.
Support different storage for Raft log: `Bitcask` and `Badger` via `--storage` flag
# What is Raft consensus?
Please refer to this [page](https://raft.github.io/) for more detail.# How to run
Clone the project:
```
git clone https://github.com/ldmtam/raft-auto-increment
```Change directory to `raft-auto-increment`
```
cd raft-auto-increment
```Start `node 1`, this node will be the leader by default. `node 1` will serve requests at port `3000`.
```
make run1
```Start other 2 nodes by running following commands. `node 2` and `node 3` will be slaves of `node 1` and serve requests at port `13000`, `23000` respectively.
```
make run2
make run3
```Get next available ID for key `foo`:
```
curl http://localhost:3000/auto-increment/one/foo
```Get last inserted ID for key `foo`:
```
curl http://localhost:3000/auto-increment/last-inserted/foo
```Get next 10 available IDs for key `bar`:
```
curl http://localhost:3000/auto-increment/many/bar/10
```You can send request to `node 2` and `node 3` as well. Requests will be automatically forwarded to master node (`node 1`),
```
curl http://localhost:13000/auto-increment/one/bar
``````
curl http://localhost:23000/auto-increment/last-inserted/bar
```