example

command
v0.0.0-...-bff849b Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

Example

A basic key/val memory store of how to use gossip.

Install

go get github.com/shimingyah/gossip
go build gossip.go delegate.go

Cluster

start first node

./gossip -gossipPort=60001 -httpPort=8081

start second node join the first node

./gossip -gossipPort=60002 -httpPort=8082 -join=127.0.0.1:60001

start third node

./gossip -gossipPort=60003 -httpPort=8083 -join=127.0.0.1:60001,127.0.0.1:60002

the three nodes will communicate with each other.

Http API

  • /has - check key if is exist
  • /get - get value
  • /set - set key value
  • /del - del key

use example:

# set
curl "http://127.0.0.1:8081/set?key=foo&val=bar"
# get
curl "http://127.0.0.1:8081/get?key=foo"
# has
curl "http://127.0.0.1:8081/has?key=foo"
# del
curl "http://127.0.0.1:8081/del?key=foo"

Consistency check

fisrt set key on http server 8081, set k-v successful.

curl "http://127.0.0.1:8081/set?key=foo&val=bar"

second get key on http server 8082, you can get it.

curl "http://127.0.0.1:8082/get?key=foo"

third del key on http server 8083, del k-v successful.

curl "http://127.0.0.1:8083/del?key=foo"

fourthly has key on http server 8082, it will return not found.

curl "http://127.0.0.1:8082/has?key=foo"

the end get key on http server 8081, it will return not found.

curl "http://127.0.0.1:8081/get?key=foo"

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