All Projects → libopenstorage → gossip

libopenstorage / gossip

Licence: Apache-2.0 license
Go implementation of the Gossip protocol

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

gossip

Travis branch Code Coverage

Go implementation of the Gossip protocol.

Overview

This package provides an implementation of an eventually consistent in-memory data store. The data store values are exchanged using a push-pull gossip protocol.

// Create a gossiper
g := NewGossiper("<ip>:<port>", "<unique node id>", "<peer-list>")
// Add peer nodes with whom you want to gossip
g.AddNode("<peer_ip>:<peer_port>")
...
// update self values
g.UpdateSelf("<some_key>", "<any_value>")
// start gossip
g.Start()

These values are exchanged using the gossip protocol between the configured peers.

// Get the current view of the world
storeKeys = g.GetStoreKeys()
for _, key := range storeKeys.List {
	nodeInfoMap := g.GetStoreKeyValue(key)
	for id,  nodeInfo := nodeInfoList.List {
		// if nodeInfo.Status != types.NODE_STATUS_INVALID
        // then nodeInfo has valid data.
	}
}

// Stop gossiping
g.Stop()

Contributing

Testing

To test, run make test. This will run the unit tests

Vendoring

For vendoring, we use dep. Some useful dep commands are:

  • dep ensure: install the project's dependencies
  • dep ensure -update: update the locked versions of all dependencies
  • dep ensure -add github.com/pkg/errors: add a dependency to the project
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].