From: ahoward Date: 2003-01-31T06:03:32+09:00 Subject: drb experts drb'ing ruby'ists- what is the preferred method of server a 'live' ruby object, eg one holding resources on the local machine, like database connections a) distribute the connections directly, perhaps starting a new DrbServer (once only) for each connection - returning this object to the clients silly (pseudo-code) : class PGconn include DRbUndumped end class PgSqlConnPool def initialize (*databases) @pgconns = {} databases.map {|db| @pgconns[db] = PGconn.new db } end def pgconn db DRbObject.new(nil, (DRb::DRbServer.new(nil, @pgconn[db]).uri) end end b) return a proxy object knowing it's Drb parent, where methods called on the proxy relay into calls on the main Drb server silly (pseudo-code) : class PGconnProxy include DRbUndumped def initialize drb, db @drb = drb @db = db end def query sql @drb.query db, sql end end class PgSqlConnPool def initialize (*databases) @pgconns = {} databases.map {|db| @pgconns[db] = PGconn.new db } end def pgconn db PGconnProxy.new DRbObject.new(nil, self.uri), db end def query db, sql @pgconns[db].query sql end end obviously i know very little about drb - but hopefully the overall design will come through in my bad code. i'm hopefull that i'll be able to work out the details myself. i'm really interested in the best overall design stratagy. -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================