Skip to content

fault tolerant Key-Value store based on RAFT protocol

License

Notifications You must be signed in to change notification settings

sarthakvk/gokey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gokey: Distributed key-value store

Documentation: For complete documentation, see the associated Godoc

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:
      go run cmd/httpd/httpd.go -node-id A -address localhost:8000 -http-port 9000 -bootstrap
      go run cmd/httpd/httpd.go -node-id B -address localhost:8001 -http-port 9001
      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:
      curl --location 'localhost:9000/add-replica' \
      --header 'Content-Type: application/json' \
      --data '{
          "node_id": "B",
          "address": "localhost:8001"
      }'
    • Add node C to the cluster:
      curl --location 'localhost:9000/add-replica' \
      --header 'Content-Type: application/json' \
      --data '{
          "node_id": "C",
          "address": "localhost:8002"
      }'
  • Examples:
    1. SET:
      • Request:
        curl --location 'localhost:9000/key-store' \
        --header 'Content-Type: application/json' \
        --data '{
            "command": "SET",
            "key": "FOO",
            "value": "BAR"
        }'
      • Response:
        {"created":true}
    2. DELETE:
      • Request:
        curl --location 'localhost:9000/key-store' \
        --header 'Content-Type: application/json' \
        --data '{
            "command": "DELETE",
            "key": "FOO"
        }'
    3. GET_OR_CREATE:
      • Request:
        curl --location 'localhost:9000/key-store' \
        --header 'Content-Type: application/json' \
        --data '{
            "command": "GET_OR_CREATE",
            "key": "FOO",
            "value": "FOO"
        }'
      • Response:
        {"value":"BAR"}

About

fault tolerant Key-Value store based on RAFT protocol

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages