https://github.com/sarthakvk/gokey
fault tolerant Key-Value store based on RAFT protocol
https://github.com/sarthakvk/gokey
golang-application raft-consensus-algorithm
Last synced: 2 months ago
JSON representation
fault tolerant Key-Value store based on RAFT protocol
- Host: GitHub
- URL: https://github.com/sarthakvk/gokey
- Owner: sarthakvk
- License: mit
- Created: 2024-01-18T14:57:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-03T18:14:59.000Z (about 2 years ago)
- Last Synced: 2024-06-21T15:36:24.277Z (almost 2 years ago)
- Topics: golang-application, raft-consensus-algorithm
- Language: Go
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gokey: Distributed key-value store
**Documentation**: For complete documentation, see the associated [Godoc](https://pkg.go.dev/github.com/sarthakvk/gokey)
--
**Usage:**
**This is still under development, don't use in PRODUCTION**
* **Application Prerequisites:**
- Make sure go is installed version >= 1.21
- Clone the repository
* **Application Startup:**
- Execute the following commands to initiate the nodes:
```bash
go run cmd/httpd/httpd.go -node-id A -address localhost:8000 -http-port 9000 -bootstrap
```
```bash
go run cmd/httpd/httpd.go -node-id B -address localhost:8001 -http-port 9001
```
```bash
go run cmd/httpd/httpd.go -node-id C -address localhost:8002 -http-port 9002
After successfully launching the nodes, ensure that the leader node (i.e., `node A`, as it was designated with the bootstrap option) adds the other two nodes to the cluster.
* **Adding Nodes API:**
- Add node B to the cluster:
```bash
curl --location 'localhost:9000/add-replica' \
--header 'Content-Type: application/json' \
--data '{
"node_id": "B",
"address": "localhost:8001"
}'
```
- Add node C to the cluster:
```bash
curl --location 'localhost:9000/add-replica' \
--header 'Content-Type: application/json' \
--data '{
"node_id": "C",
"address": "localhost:8002"
}'
```
- **Examples:**
1. **SET:**
- **Request:**
```bash
curl --location 'localhost:9000/key-store' \
--header 'Content-Type: application/json' \
--data '{
"command": "SET",
"key": "FOO",
"value": "BAR"
}'
```
- **Response:**
```json
{"created":true}
```
2. **DELETE:**
- **Request:**
```bash
curl --location 'localhost:9000/key-store' \
--header 'Content-Type: application/json' \
--data '{
"command": "DELETE",
"key": "FOO"
}'
```
3. **GET_OR_CREATE:**
- **Request:**
```bash
curl --location 'localhost:9000/key-store' \
--header 'Content-Type: application/json' \
--data '{
"command": "GET_OR_CREATE",
"key": "FOO",
"value": "FOO"
}'
```
- **Response:**
```json
{"value":"BAR"}
```