example

command
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

raftexample

raftexample is an example usage of raft-foiver. It provides a simple REST API for a key-value store cluster backed by the Raft Consensus Algorithm. Inspired by etcd/contrib/raftexample.

Usage

Build

Clone raft-foiver.

cd raftexample
go build -o raftexample
Start a Three-Node Cluster
  1. Start Cluster
goreman start
  1. Add Key-Value
  • key: hello
  • value: world
curl -L http://127.0.0.1:9999/hello -X POST -d world
  1. Get Key-Value
curl -L http://127.0.0.1:9999/hello
Fault Tolerance
  1. Start Cluster and Add Key-Value (hello:world)
goreman start
curl -L http://127.0.0.1:9999/hello -X POST -d world
  1. Stop a Node and Update Key-Value (hello:foiver)
goreman run stop raftexample3
curl -L http://127.0.0.1:7777/hello -X POST -d foiver
curl -L http://127.0.0.1:7777/hello
  1. Restart Node and Check Key-Value (hello:foiver)
goreman run start raftexample3
curl -L http://127.0.0.1:9999/hello
Dynamic Cluster Reconfiguration
  1. Start Three-Node Cluster
goreman start
  1. Add New Node to Cluster
curl -L http://127.0.0.1:9999/4 -X PUT -d localhost:6000
raftexample --id 4 --addr localhost:6000 --peerids 1,2,3 --peeraddrs localhost:7000,localhost:8000,localhost:9000 --port 6666 --join
  1. Test Cluster
curl -L http://127.0.0.1:9999/hello -X POST -d world
curl -L http://127.0.0.1:6666/hello
  1. Remove Node from Cluster
curl -L http://127.0.0.1:9999/2 -X DELETE

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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