gossip

package module
v0.0.0-...-da5cc4f Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2014 License: GPL-3.0 Imports: 8 Imported by: 1

README

gossip - a simple service discovery protocol
============================================

``gossip`` is a service discovery protocol that can broadcast
application-specific data across a number of participant nodes.

The underlying protocol is very simple. It is based on random
gossiping between participants, and it provides a few useful
characteristics:

* the probability of falsely reporting a node as failed is known

* the algorithm is resilient against network loss and it will recover
  from network partitioning

* detection time scales with the number of nodes as *O(n log n)*

The implementation uses Go's own ``net/rpc`` RPC module.

Documentation

Overview

A gossip-based discovery service.

This package is based on some of the ideas found in the paper "A Gossip-Style Failure Detection Service" by van Renesse, Minsky, Hayden[1].

[1] http://www.cs.cornell.edu/home/rvr/papers/GossipFD.pdf

(c) 2014 <ale@incal.net>. See the file COPYING for details.

Index

Constants

This section is empty.

Variables

View Source
var (
	// How many propagation constants one node must miss in order
	// for it to be considered dead (scales with the observed
	// cluster size).
	Nfailures = 3

	// How often to broadcast to other nodes (default).
	Tgossip = 1 * time.Second

	// RPC deadline (default).
	Trpc = 5 * time.Second
)

Functions

This section is empty.

Types

type GetMembersRequest

type GetMembersRequest struct{}

type GetMembersResponse

type GetMembersResponse struct {
	Members []Member
}

type Gossip

type Gossip struct {

	// Updates channel.
	C chan bool

	// Set to true to enable debug output.
	DebugOutput bool

	// Timeouts.
	Tgossip time.Duration
	Trpc    time.Duration
	// contains filtered or unexported fields
}

Gossip represents a participant in the protocol. It contains the full connection state and membership information.

Example:

g = New(...)
go g.Run()
for {
        <-g.C
        // do something with the member list
}

A separate goroutine should periodically call gossip.SetData() to update the application-specific local state which is shared with the other peers.

func New

func New(addr string, data interface{}, otherNodes []string) *Gossip

func (*Gossip) Close

func (g *Gossip) Close()

func (*Gossip) FailureTime

func (g *Gossip) FailureTime() time.Duration

FailureTime returns the current time after which a node is considered dead. It is based on the gossip tick interval and the observed cluster size.

func (*Gossip) GetMembers

func (g *Gossip) GetMembers() []Member

Return the list of active members.

func (*Gossip) Receive

func (g *Gossip) Receive(update []Member)

Receive a remote update.

func (*Gossip) Run

func (g *Gossip) Run()

Run starts the node (does not return).

func (*Gossip) SetData

func (g *Gossip) SetData(data interface{})

SetData updates the application-specific data for this node.

type GossipRequest

type GossipRequest struct {
	Members []Member
}

type GossipResponse

type GossipResponse struct{}

type Member

type Member struct {
	// Address of this node (host:port).
	Addr string

	// Heartbeat counter.
	Heartbeat int64

	// Application-specific data.
	Data interface{}
}

Member represents a participant in the gossip protocol. Applications can provide opaque data, which will be broadcasted to all the other participants.

func (*Member) String

func (m *Member) String() string

Directories

Path Synopsis
An example implementation of a gossip-based service.
An example implementation of a gossip-based service.
Collect and print statistics on a running cluster.
Collect and print statistics on a running cluster.

Jump to

Keyboard shortcuts

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