ROMP - The Ruby Object Message Proxy(C) Copyright 2001 Paul Brannan (cout at rm-f.net)
ROMP is a set of classes for providing distributed object support to a Ruby program. You may distribute and/or modify it under the same terms as Ruby (see http://www.ruby-lang.org/en/LICENSE.txt). Example: Client ------ client = ROMP::Client.new('localhost', 4242) obj = client.resolve("foo") puts obj.foo("foo") obj.oneway(:foo, "foo") Server ------ class Foo def foo(x); return x; end end obj = Foo.new server = ROMP::Server.new('localhost', 4242) server.bind(obj, "foo") server.thread.join You can do all sorts of cool things with ROMP, including passing blocks to the functions, throwing exceptions and propogating them from server to client, and more. Unlike CORBA, where you must create an interface definition and strictly adhere to it, ROMP uses marshalling, so you can use almost any object with it. But, alas, it is not as powerful as CORBA. On a fast machine, you should expect around 7000 messages per second with normal method calls, up to 10000 messages per second with oneway calls with sync, and up to 40000 messages per second for oneway calls without sync. The ROMP message format is broken into 3 components: [ msg_type, obj_id, message ] For each msg_type, there is a specific format to the message. Additionally, certain msg_types are only valid when being sent to the server, and others are valid only when being sent back to the client. Here is a summary: msg_type send to meaning of obj_id msg format ---------------------------------------------------------------------------- REQUEST server obj to talk to [:method, *args] REQUEST_BLOCK server obj to talk to [:method, *args] ONEWAY server obj to talk to [:method, *args] ONEWAY_SYNC server obj to talk to [:method, *args] RETVAL client always 0 retval EXCEPTION client always 0 $! YIELD client always 0 [value, value, ...] SYNC either 0=request, 1=response nil NULL_MSG either always 0 n/a BUGS: - On a 2.2 kernel, oneway calls without sync is very slow. - UDP support does not currently work.
Author: Paul Brannan
class Server < ObjectThe ROMP server class. Like its drb equivalent, this class spawns off a new thread which processes requests, allowing the server to do other things while it is doing processing for a distributed object. This means, though, that all objects used with ROMP must be thread-safe.
initialize(endpoint, acceptor=nil, debug=false)
Register an object with the server. The object will be given an
id of @next_id, and @next_id will be incremented. We could use the
object's real id, but this is insecure. The supplied object must
This keeps the client from seeing our objects when they call inspect
class Client < ObjectThe ROMP client class. A ROMP server must be started on the given host and port before instantiating a ROMP client.
Given a string, return a proxy object that will forward requests
for an object on the server with that name.
class Null_Mutex < ObjectIn case the user does not want synchronization.
class Functions < ObjectAll the special functions we have to keep track of
class Object_Reference < ObjectA ROMP::Object_Reference is created on the server side to represent an object in the system. It can be returned from a server object to a client object, at which point it is converted into a ROMP::Proxy_Object.
class Proxy_Object < ObjectA ROMP::Object acts as a proxy; it forwards most methods to the server for execution. When you make calls to a ROMP server, you will be making the calls through a Proxy_Object.
class Resolve_Server < ObjectThe Resolve_Server class registers objects for the server. You will never have to use this class directly.
class Resolve_Obj < ObjectThe Resolve_Obj class handles resolve requests for the client. It is a special ROMP object with an object id of 0. You will never have to make calls on it directly, but will instead make calls on it through the Client object.
class Generic_Server < ObjectA Generic_Server creates an endpoint to listen on, waits for connections, and accepts them when requested. It can operate on different kinds of connections. You will never have to use this object directly.
class Generic_Client < ObjectA Generic_Client connects to a Generic_Server on a given endpoint. You will never have to use this object directly.
class Session < ObjectThe Sesssion class is defined in romp_helper.so. You should never have to use it directly.
Requires / Includessocket