rgossip

Description

Basic implementation of a gossip protocol.

This is a porting of Java implementation.

see code.google.com/p/gossip-protocol-java/

Install

gem install rgossip

Example

require 'rubygems'
require 'rgossip'

#RGossip.debug = true
#RGossip.port = 20870 # default: 10870(udp)

gossip = RGossip::Client.new ['10.150.174.161', '10.150.185.250', '10.150.174.30']
# RGossip::Client#initialize(initial_nodes = [], address = nil,  data = nil)

gossip.data = 'node-1'
gossip.start
#gossip.join

loop do
  case gets
  when /list/i
    gossip.each do |address, timestamp, data|
      puts "#{address}: #{data}"
      # (example output)
      # 10.150.174.161: node-1
      # 10.150.174.30: node-3
      # 10.150.185.250: node-2
    end
  when /^add\s+(.+)$/
    gossip.add_node $1
  end
end