raftkv

command module
v0.0.0-...-d3bda19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 11 Imported by: 0

README

raftkv

This repository holds a simple leader-followers key-value store by using hashicorp/raft. raftkv provides gRPC and HTTP APIs. Please take a look API Reference.

Usage

Run containers
docker compose up
Validation

Set a key-value to a leader.

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.

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.

curl -XDELETE 'localhost:50002/v1/delete/programming_language'
curl -XGET 'localhost:50102/v1/get/programming_language'
curl -XGET 'localhost:50202/v1/get/programming_language'
{"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 in detail.

curl -XPOST 'localhost:50102/v1/set' \
--data-raw '{
    "key": "programming_language",
    "value": "golang"
}'
curl -XDELETE 'localhost:50102/v1/delete/programming_language'
{"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":[]}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
proto
v1
Package raftkvpb is a reverse proxy.
Package raftkvpb is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL