- Notifications
You must be signed in to change notification settings - Fork1
ldmtam/raft-auto-increment
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Distributed, fault-tolerant, persistent, auto-increment ID generation service with Raft consensus.
Support bothREST API
andgRPC
protocol.
Support different storage for Raft log:Bitcask
andBadger
via--storage
flag
Please refer to thispage for more detail.
Clone the project:
git clone https://github.com/ldmtam/raft-auto-increment
Change directory toraft-auto-increment
cd raft-auto-increment
Startnode 1
, this node will be the leader by default.node 1
will serve requests at port3000
.
make run1
Start other 2 nodes by running following commands.node 2
andnode 3
will be slaves ofnode 1
and serve requests at port13000
,23000
respectively.
make run2make run3
Get next available ID for keyfoo
:
curl http://localhost:3000/auto-increment/one/foo
Get last inserted ID for keyfoo
:
curl http://localhost:3000/auto-increment/last-inserted/foo
Get next 10 available IDs for keybar
:
curl http://localhost:3000/auto-increment/many/bar/10
You can send request tonode 2
andnode 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