Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keisku/raftkv
A simple distributed key-value store by using hashicorp/raft
https://github.com/keisku/raftkv
go golang grpc grpc-gateway hashicorp hashicorp-raft raft raft-algorithm raft-example
Last synced: 28 days ago
JSON representation
A simple distributed key-value store by using hashicorp/raft
- Host: GitHub
- URL: https://github.com/keisku/raftkv
- Owner: keisku
- License: mit
- Created: 2021-12-01T06:43:25.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-07T23:13:37.000Z (almost 3 years ago)
- Last Synced: 2023-06-27T22:28:27.070Z (over 1 year ago)
- Topics: go, golang, grpc, grpc-gateway, hashicorp, hashicorp-raft, raft, raft-algorithm, raft-example
- Language: Go
- Homepage:
- Size: 81.1 KB
- Stars: 6
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# raftkv
This repository holds a simple leader-followers key-value store by using [hashicorp/raft](https://github.com/hashicorp/raft).
`raftkv` provides gRPC and HTTP APIs. Please take a look [API Reference](./proto/v1/README.md).## Usage
### Run containers
```shell
docker compose up
```### Validation
Set a key-value to a leader.
```shell
curl -XPOST 'localhost:50002/v1/set' \
--data-raw '{
"key": "programming_language",
"value": "golang"
}'
```Get a value from a follower.
You will get "golang" from followers. It means a leader propagates the value to followers.```shell
curl -XGET 'localhost:50102/v1/get/programming_language'
curl -XGET 'localhost:50202/v1/get/programming_language'
```Delete a key-value.
You will get "not found" errors from followers.```shell
curl -XDELETE 'localhost:50002/v1/delete/programming_language'
``````shell
curl -XGET 'localhost:50102/v1/get/programming_language'
curl -XGET 'localhost:50202/v1/get/programming_language'
``````json
{"code":5, "message":"not found", "details":[]}
{"code":5, "message":"not found", "details":[]}
```If you try to set or delete a key-value to a follower, you will get an error.
`localhost:50102` is an address for a follower at this time and you can replace it with `localhost:50201` too.See the [docker-compose.yaml](./docker-compose.yaml) in detail.
```shell
curl -XPOST 'localhost:50102/v1/set' \
--data-raw '{
"key": "programming_language",
"value": "golang"
}'
curl -XDELETE 'localhost:50102/v1/delete/programming_language'
``````json
{"code":13, "message":"non-leader can't set key=programming_language, value=golang", "details":[]}
{"code":13, "message":"non-leader can't delete a value associated to programming_language", "details":[]}
```