From: Steve Tuckner Date: 2003-08-08T07:09:42+09:00 Subject: Re: [DRb] Using DRb to implement object database This is a multi-part message in MIME format. ------=_NextPart_000_0056_01C35D06.AD6D8A50 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit > DRb provides a remote 'facade' to a single object on a > particular port, 9000 > in this case. So you create a single object which contains a > set of methods > which do all the different work parcels you want - including invoking > methods on other objects if necessary. Yes I agree. > > That's unless you want a separate DRb front-end to each individual Foo > object, which would mean binding them to separate TCP ports. > That's not an > approach I would recommend unless you've only got two or > three objects you > want to access remotely. > I also agree. > If you decided to make the PStore object itself available by > DRb, I don't > If DRbUndumped automatically puts in some kind of > proxy-object for each > remote object on the server, then that would be very cool > indeed. This it seems to do. Any object that is returned by a remote method call is proxied if it includes DRbUndumped. If you look at my attached example. If you comment out the include of DRbUndumped, you will see that the object returned is not a DRbObject and thus all changes to the A class object are local. > see your problem with PStore, which relies on being able to > dump objects to > get them to disk. Have you tried just commenting out the > _dump function? It > looks like DRb only tests whether the module has been included: > > obj = DRbObject.new(obj) if obj.kind_of? DRbUndumped > > Hence it probably doesn't actually need _dump to be overridden. > I tried to comment out the _dump redefinition in the module DRbUndumped and the proxying no longer worked. I am not sure why. Steve Tuckner ------=_NextPart_000_0056_01C35D06.AD6D8A50 Content-Type: application/octet-stream; name="a.rb" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="a.rb" require "drb" class A attr_accessor :x, :y #include DRbUndumped def initialize(x,y) @x = x @y = y end end ------=_NextPart_000_0056_01C35D06.AD6D8A50 Content-Type: application/octet-stream; name="c.rb" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="c.rb" require "drb" require "a" DRb.start_service od = DRbObject.new(nil, "druby://localhost:9000") a = od[0] puts "at beginning, a.inspect = #{a.inspect}" puts "at beginning, od[0].x = #{a.x.inspect}" a.x = 4 puts "at end, a.x = #{a.x.inspect}" puts "at end, od[0].x = #{od[0].x.inspect} and should be 4" ------=_NextPart_000_0056_01C35D06.AD6D8A50 Content-Type: application/octet-stream; name="s.rb" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="s.rb" require "drb" require "a" od = [A.new(1,2)] puts "at beginning, od[0].x = #{od[0].x.inspect}" DRb.start_service('druby://localhost:9000', od) print "DRb server waiting...\n" begin while true sleep 1 print "." end rescue Exception puts "were done\n" puts "at end, od[0].x = #{od[0].x.inspect}" end ------=_NextPart_000_0056_01C35D06.AD6D8A50--