drb’ing ruby’ists-
i am confused (in general, but especially on this topic) :
i was under the impression that if one was to NOT include DRbUndumped in a
class that client’s using the class remotely would be required to load any
client libraries. if that is the case, then this would not work, and yet it
does?
~/eg/ruby/dpostgres > cat s.rb && s.rb
#!/usr/bin/env ruby
require ‘postgres’
require ‘drb’
DRb.start_service ‘druby://localhost:5000’, PGconn.new
DRb.thread.join
~/eg/ruby/dpostgres > cat c.rb && c.rb
#!/usr/bin/env ruby
require ‘drb’
DRb.start_service
pgconn = DRbObject.new nil, ‘druby://localhost:5000’
pgresult = pgconn.exec (ARGV.shift or ‘select * from foo’)
p pgresult.result
pgresult.clear
[[“2003-02-04 10:23:34.522356-07”, “2003-02-05 00:00:00-07”]]
note that the client does NOT do “require ‘postgres’” ???
very confused.
-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
====================================
Mayhap this is happening:
def dump(obj, ary)
obj = DRbObject.new(obj) if obj.kind_of? DRbUndumped
begin
str = Marshal::dump(obj)
rescue
ro = DRbObject.new(obj)
str = Marshal::dump(ro)
end
ary.push([str.size].pack(‘N’) + str) if ary
return str
end
try this:
ruby -r postgres -e “Marshal::dump(PGConn.new)”
If you get an exception, then DRb DTRT (Did The Right Thing) and wrapped
the un-dumpable object in a proxy for you.
Note that DRb does the right thing with this:
require ‘drb’
DRb.start_service(‘druby://localhost:5000’, File.new(‘server.rb’))
DRb.thread.join
···
ahoward (ahoward@fsl.noaa.gov) wrote:
drb’ing ruby’ists-
i am confused (in general, but especially on this topic) :
i was under the impression that if one was to NOT include DRbUndumped in a
class that client’s using the class remotely would be required to load any
client libraries. if that is the case, then this would not work, and yet it
does?
~/eg/ruby/dpostgres > cat s.rb && s.rb
#!/usr/bin/env ruby
require ‘postgres’
require ‘drb’
DRb.start_service ‘druby://localhost:5000’, PGconn.new
DRb.thread.join
~/eg/ruby/dpostgres > cat c.rb && c.rb
#!/usr/bin/env ruby
require ‘drb’
DRb.start_service
pgconn = DRbObject.new nil, ‘druby://localhost:5000’
pgresult = pgconn.exec (ARGV.shift or ‘select * from foo’)
p pgresult.result
pgresult.clear
[[“2003-02-04 10:23:34.522356-07”, “2003-02-05 00:00:00-07”]]
note that the client does NOT do “require ‘postgres’” ???
–
Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
try this:
ruby -r postgres -e “Marshal::dump(PGConn.new)”
/usr/local/lib/ruby/1.8 > ruby -r postgres -e “Marshal::dump(PGconn.new)”
-e:1:in dump': class PGconn needs to have instance method
_dump_data’
(TypeError) from -e:1
you are correct. so it seems the ONLY way to design a connection pool for
PGconns is via proxy object
my initial test show that the typical connect/select/display pattern of a cgi
program will experience a speed up of around 2-8 times over making a direct
connection - assuming a smallish (< 3000 tuples) result set. i’m not sure how
well the threading will scale respecting access to this one connection, but
priliminary tests make this look promising for ‘normal’ cgi type programs.
If you get an exception, then DRb DTRT (Did The Right Thing) and wrapped the
un-dumpable object in a proxy for you.
what a fantastic peice of code! i bet it realizes this in any case where the
required module is an *.so since this would always be un-dumpable…
Note that DRb does the right thing with this:
require ‘drb’
DRb.start_service(‘druby://localhost:5000’, File.new(‘server.rb’))
DRb.thread.join
i assume this means you can define your server class in a file and serve it
that way? does that then mean it would be inpossible to distribute, for
example, a log file?
-a
ps. thanks for the reply.
···
On Wed, 5 Feb 2003, Eric Hodel wrote:
–
====================================
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
====================================
No, you just get a File object back. I should have included the client
code:
require ‘drb’
DRb.start_service
obj = DRbObject.new(nil, ‘druby://localhost:5000’)
p obj # => DRBObject
p obj.read # => file contents
obj.close # must close, as server won’t do it until exit
···
ahoward (ahoward@fsl.noaa.gov) wrote:
On Wed, 5 Feb 2003, Eric Hodel wrote:
Note that DRb does the right thing with this:
require ‘drb’
DRb.start_service(‘druby://localhost:5000’, File.new(‘server.rb’))
DRb.thread.join
i assume this means you can define your server class in a file and serve it
that way? does that then mean it would be inpossible to distribute, for
example, a log file?
–
Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04