raft-example

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

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 12 Imported by: 0

README

Minimal hashicorp/raft example

Example:

Terminal 1:

$ go build
$ ./raft-example --node-id node1 --raft-port 2222 --http-port 8222

Terminal 2:

$ go build
$ ./raft-example --node-id node2 --raft-port 2223 --http-port 8223

Terminal 3, tell 1 to have 2 follow it:

$ curl 'localhost:8222/join?followerAddr=localhost:2223&followerId=node2'

Terminal 3, now add a key:

$ curl -X POST 'localhost:8222/set' -d '{"key": "x", "value": "23"}' -H 'content-type: application/json'

Terminal 3, now get the key from either server:

$ curl 'localhost:8222/get?key=x'
{"data":"23"}
$ curl 'localhost:8223/get?key=x'
{"data":"23"}

References:

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