Rinda is a software library for creating modular and distributed co-operating services in
Ruby
A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called ...
using the
tuple space
A tuple space is an implementation of the associative memory paradigm for parallel/distributed computing. It provides a repository of tuples that can be accessed concurrently. As an illustrative example, consider that there are a group of process ...
or
Linda
Linda may refer to:
As a name
* Linda (given name), a female given name (including a list of people and fictional characters so named)
* Linda (singer) (born 1977), stage name of Svetlana Geiman, a Russian singer
* Anita Linda (born Alice Lake i ...
distributed computing
A distributed system is a system whose components are located on different networked computers, which communicate and coordinate their actions by passing messages to one another from any system. Distributed computing is a field of computer sci ...
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 (DRb) 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 (which or may not be running on the same machine) can add, access and modify
tuple
In mathematics, a tuple is a finite ordered list (sequence) of elements. An -tuple is a sequence (or ordered list) of elements, where is a non-negative integer. There is only one 0-tuple, referred to as ''the empty tuple''. An -tuple is defi ...
s (an ordered list of elements) stored in a shared data repository (the tuplespace).
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(URI, Rinda::TupleSpace.new)
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 (such as the sequence "+ 2 4") When such a tuple is discovered the program computes the result of the mathematical operation (for example, processing "+ 2 4" into "6") and stores it in tuplespace.
require 'rinda/rinda'
URI = "druby://localhost:61676"
DRb.start_service
ts = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, URI))
loop do
ops, a, b = ts.take( %r, Numeric, Numeric
ts.write( result", a.send(ops, b)
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 (posted by the program above).
require 'rinda/rinda'
URI = "druby://localhost:61676"
DRb.start_service
ts = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, URI))
tuples = "*", 2, 2 "+", 2, 5 "-", 9, 3
tuples.each do , t,
ts.write(t)
res = ts.take( result", nil
puts "# = # # #"
end
External links
Ruby Standard Library Documentation for Rinda
References
Ruby (programming language)
Inter-process communication
{{programming-software-stub