dRuby is a distributed object environment for Ruby. dRuby and Rinda are part of Ruby stdlib.
- RMI (remote method invocation) library
- extends Ruby method calls across the network
- allows calling object methods from other processes or machines
- written completely in Ruby
Rinda:
- shared tuplespace implementation.
- co-ordination mechanism running on dRuby.
- implementation of linda co-ordination language in Ruby
Rules for passing objects between client and server:
- serializable objects are passed by value
- non-serializable - by reference
Example code
# server.rb
require 'drb/drb'
queue = SizedQueue.new(100)
DRb.start_service('druby://localhost:9999', queue)
DRb.thread.join
# publisher.rb
require 'drb/drb'
DRb.start_service
q = DRbObject.new_with_uri('druby://localhost:9999')
100.times do |n|
sleep(rand)
q.push(n)
end
# consumer.rb
require 'drb/drb'
DRb.start_service
q = DRbObject.new_with_uri('druby://localhost:9999')
100.times do |n|
sleep(rand)
puts q.pop
end
Articles
- dRuby and Rinda: Implementation and application of distributed Ruby and its parallel coordination mechanism
- dRuby documentation
- Reflection, Object Space and Distributed Ruby
- dRb on Wikibooks
- Rinda 101
- Exploring Tuple Spaces Persistence In Ruby With Blackboard
- dRuby for penetration testers
- An Introduction to Distributed Ruby