summaryrefslogtreecommitdiff
path: root/lib/drb/gw.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-25 03:25:39 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-25 03:25:39 +0000
commit90e69dfdaf0b603f3adef052274a4a73bde6e901 (patch)
tree3d2f574f9d0e5dceb08057ebea985f3857c807b9 /lib/drb/gw.rb
parentd50bd4939a79bb53aeaf8c607e3d6612d3167022 (diff)
* lib/drb/drb.rb: Improved documentation by adding or hiding methods.
* lib/drb/eq.rb: ditto. * lib/drb/extserv.rb: ditto. * lib/drb/gw.rb: ditto. * lib/drb/invokemethod.rb: ditto. * lib/drb/observer.rb: ditto. * lib/drb/ssl.rb: ditto. * lib/drb/timeridconv.rb: ditto. * lib/drb/unix.rb: ditto. * sample/drb/gw_cu.rb: Fixed bug in DRb gateway sample. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/drb/gw.rb')
-rw-r--r--lib/drb/gw.rb42
1 files changed, 40 insertions, 2 deletions
diff --git a/lib/drb/gw.rb b/lib/drb/gw.rb
index b7a5f53..b3568ab 100644
--- a/lib/drb/gw.rb
+++ b/lib/drb/gw.rb
@@ -2,8 +2,36 @@ require 'drb/drb'
require 'monitor'
module DRb
+
+ # Gateway id conversion forms a gateway between different DRb protocols or
+ # networks.
+ #
+ # The gateway needs to install this id conversion and create servers for
+ # each of the protocols or networks it will be a gateway between. It then
+ # needs to create a server that attaches to each of these networks. For
+ # example:
+ #
+ # require 'drb/drb'
+ # require 'drb/unix'
+ # require 'drb/gw'
+ #
+ # DRb.install_id_conv DRb::GWIdConv.new
+ # gw = DRb::GW.new
+ # s1 = DRb::DRbServer.new 'drbunix:/path/to/gateway', gw
+ # s2 = DRb::DRbServer.new 'druby://example:10000', gw
+ #
+ # s1.thread.join
+ # s2.thread.join
+ #
+ # Each client must register services with the gateway, for example:
+ #
+ # DRb.start_service 'drbunix:', nil # an anonymous server
+ # gw = DRbObject.new nil, 'drbunix:/path/to/gateway'
+ # gw[:unix] = some_service
+ # DRb.thread.join
+
class GWIdConv < DRbIdConv
- def to_obj(ref)
+ def to_obj(ref) # :nodoc:
if Array === ref && ref[0] == :DRbObject
return DRbObject.new_with(ref[1], ref[2])
end
@@ -11,19 +39,29 @@ module DRb
end
end
+ # The GW provides a synchronized store for participants in the gateway to
+ # communicate.
+
class GW
include MonitorMixin
+
+ # Creates a new GW
+
def initialize
super()
@hash = {}
end
+ # Retrieves +key+ from the GW
+
def [](key)
synchronize do
@hash[key]
end
end
+ # Stores value +v+ at +key+ in the GW
+
def []=(key, v)
synchronize do
@hash[key] = v
@@ -31,7 +69,7 @@ module DRb
end
end
- class DRbObject
+ class DRbObject # :nodoc:
def self._load(s)
uri, ref = Marshal.load(s)
if DRb.uri == uri