Rinda (Ruby programming language)


Rinda is a software library for creating modular and distributed co-operating services in Ruby using the tuple space or Linda distributed computing paradigm.
Based on a source code initially released to the Ruby community by Masatoshi SEKI in 2000, Rinda was later absorbed into Ruby's core distributed Ruby module. Rinda has been distributed as part of the core Ruby library since Ruby 1.8.

Example usage

Rinda provides a framework by which multiple Ruby processes can add, access and modify tuples stored in a shared data repository.
For example, the following program creates a new Rinda tuplespace and initializes a DRb service that waits for requests coming over the network.

require 'rinda/tuplespace'
URI = "druby://localhost:61676"
DRb.start_service
DRb.thread.join

Using Rinda, other applications can poll the tuplespace for tuples that match specific criteria.
For example, the program below connects to a Rinda service and listens for any tuple composed an arithmetic operator followed two numbers When such a tuple is discovered the program computes the result of the mathematical operation and stores it in tuplespace.

require 'rinda/rinda'
URI = "druby://localhost:61676"
DRb.start_service
ts = Rinda::TupleSpaceProxy.new
loop do
ops, a, b = ts.take
ts.write
end

Finally, Rinda applications can add or remove tuples from the tuplespace.
For instance, the following program posts prefix arithmetic tuples to the tuplespace and reads back the result.

require 'rinda/rinda'
URI = "druby://localhost:61676"
DRb.start_service
ts = Rinda::TupleSpaceProxy.new
tuples = "*", 2, 2 ], , [ "-", 9, 3
tuples.each do |t|
ts.write
res = ts.take
puts "# = # # #"
end