RingyDingy 1.1.0 Released
drbrain |
RingyDingy version 1.1.0 has been released!
http://seattlerb.rubyforge.org/RingyDingy
RingyDingy automatically re-registers your DRb service with a RingServer should
communication with the RingServer stop.
Changes:
- Added ring_server executable (Rinda::RingServer wrapper)
- Daemon mode
- Rinda::RingServer service listingph
- Remote verbose mode enable-disable
- Daemon mode
- Switched to Hoe
RingyDingy-1.0.0
drbrain |
RingyDingy is a little boat that keeps your DRb service afloat!
RingyDingy automatically registers a service with a RingServer. If communication between the RingServer and the RingyDingy is lost, RingyDingy will re-register its service with the RingServer when it reappears.
Similarly, the RingServer will automatically drop registrations by a RingyDingy that it can't communicate with after a short timeout.
Installing RingyDingy
Just install the gem: gem install RingyDingy
Using RingyDingy
You'll need a Rinda::RingServer, you can download one here.
Once you've got that running you can have a service register itself:
require 'rubygems'
require 'ringy_dingy'
require 'my_drb_service'
my_drb_service = MyDRbService.new
RingyDingy.new(my_drb_service).run
DRb.thread.join
Full documentation is available from ri once you've installed the gem.
To learn more about Rinda::RingServer, you can read my handy tutorial How to use Ruby's Rinda::Ring.
Finding primes with Rinda::TupleSpace
drbrain |
While at FOSCON 2006 I watched Lucas Carlson's presentation on Rinda and DRb, but he barely scratched the surface of Rinda's capabilities with his prime finding implementation.
Rinda::TupleSpace is more powerful than just a name service for DRb. Since a TupleSpace has synchronized access to all its items, you can use a TupleSpace to coordinate processes as well.
I started rewriting Lucas' DRb using prime finder at FOSCON, but wasn't able to finish it until now. This version coordinates all the activities of the prime finding via the TupleSpace. No locking is necessary in any of the code because the TupleSpace takes care of it for us. Read more...
DRb via YAML
drbrain |
Much longer than it should be as the serialization of objects is buried inside a couple of huge methods. One tricky bit was having to mark DRbObject as not responding to #yaml_initialize, the other was marking a few undumpable classes as undumpable by YAML.
I’ll post it tomorrow when I have more brain.
TupleSpace Replicator
drbrain |
At MindCamp 2.0 I was asked about how you would replicate a TupleSpace. I whipped up the following implementation:
class Rinda::TupleSpaceReplicator
attr_accessor :debug
attr_reader :local_tuplespace, :remote_tuplespace
def initialize(remote_tuplespace, templates)
@local_tuplespace = Rinda::TupleSpace.new
@remote_tuplespace = remote_tuplespace
@templates = templates
@debug = false
@replicators = ThreadGroup.new
end
def replicate
@templates.each do |template|
%w[write take].each do |type|
make_replicator type, template
end
end
end
def make_replicator(event_type, template)
thread = Thread.start do
observer = @remote_tuplespace.notify event_type, template
observer.each do |event, tuple|
break if event == 'close'
@local_tuplespace.send event, tuple
$stderr.puts "master #{event}: #{tuple.inspect}" if @debug
end
end
@replicators.add thread
end
end
The core of this is the make_replicator method. It replicates tuples of the specified template from the remote tuplespace to the local tuplespace. Read more...
DRb an Introduction and Overview
drbrain |
I just completed my presentation on Distributed Ruby an Introduction and Overview at the Silicon Valley Ruby Conference. Free of charge you can download a PDF of the slides (720k) or the Keynote original (544k, Apple Keynote only).
Now that I have two outlines of more DRb functionality I should seriously consider writing a book on it.

