Module: DRb
- Defined in:
- lib/drb/drb.rb,
lib/drb/eq.rb,
lib/drb/gw.rb,
lib/drb/ssl.rb,
lib/drb/unix.rb,
lib/drb/extserv.rb,
lib/drb/extservm.rb,
lib/drb/observer.rb,
lib/drb/weakidconv.rb,
lib/drb/timeridconv.rb,
lib/drb/invokemethod.rb
Overview
for ruby-1.8.0
Defined Under Namespace
Modules: DRbObservable, DRbProtocol, DRbUndumped Classes: DRbArray, DRbBadScheme, DRbBadURI, DRbConn, DRbConnError, DRbError, DRbIdConv, DRbMessage, DRbObject, DRbRemoteError, DRbSSLSocket, DRbServer, DRbServerNotFound, DRbTCPSocket, DRbUNIXSocket, DRbURIOption, DRbUnknown, DRbUnknownError, ExtServ, ExtServManager, GW, GWIdConv, ThreadObject, TimerIdConv, WeakIdConv
Class Method Summary collapse
-
.config ⇒ Object
Get the configuration of the current server.
-
.current_server ⇒ Object
Get the ‘current’ server.
-
.fetch_server(uri) ⇒ Object
Retrieves the server with the given
uri. -
.front ⇒ Object
Get the front object of the current server.
-
.here?(uri) ⇒ Boolean
Is
urithe URI for the current local server?. -
.install_acl(acl) ⇒ Object
Set the default ACL to
acl. -
.install_id_conv(idconv) ⇒ Object
Set the default id conversion object.
-
.mutex ⇒ Object
:nodoc:.
-
.primary_server ⇒ Object
The primary local dRuby server.
-
.primary_server=(value) ⇒ Object
The primary local dRuby server.
-
.regist_server(server) ⇒ Object
Registers
serverwith DRb. -
.remove_server(server) ⇒ Object
Removes
serverfrom the list of registered servers. -
.start_service(uri = nil, front = nil, config = nil) ⇒ Object
Start a dRuby server locally.
-
.stop_service ⇒ Object
Stop the local dRuby server.
-
.thread ⇒ Object
Get the thread of the primary server.
-
.to_id(obj) ⇒ Object
Get a reference id for an object using the current server.
-
.to_obj(ref) ⇒ Object
Convert a reference into an object using the current server.
-
.uri ⇒ Object
Get the URI defining the local dRuby space.
Class Method Details
.config ⇒ Object
Get the configuration of the current server.
If there is no current server, this returns the default configuration. See #current_server and DRbServer::make_config.
1835 1836 1837 1838 1839 |
# File 'lib/drb/drb.rb', line 1835 def config current_server.config rescue DRbServer.make_config end |
.current_server ⇒ Object
Get the ‘current’ server.
In the context of execution taking place within the main thread of a dRuby server (typically, as a result of a remote call on the server or one of its objects), the current server is that server. Otherwise, the current server is the primary server.
If the above rule fails to find a server, a DRbServerNotFound error is raised.
1792 1793 1794 1795 1796 1797 |
# File 'lib/drb/drb.rb', line 1792 def current_server drb = Thread.current['DRb'] server = (drb && drb['server']) ? drb['server'] : @primary_server raise DRbServerNotFound unless server return server end |
.fetch_server(uri) ⇒ Object
Retrieves the server with the given uri.
See also regist_server and remove_server.
1937 1938 1939 |
# File 'lib/drb/drb.rb', line 1937 def fetch_server(uri) @server[uri] end |
.front ⇒ Object
Get the front object of the current server.
This raises a DRbServerNotFound error if there is no current server. See #current_server.
1846 1847 1848 |
# File 'lib/drb/drb.rb', line 1846 def front current_server.front end |
.here?(uri) ⇒ Boolean
Is uri the URI for the current local server?
1825 1826 1827 1828 |
# File 'lib/drb/drb.rb', line 1825 def here?(uri) current_server.here?(uri) rescue false # (current_server.uri rescue nil) == uri end |
.install_acl(acl) ⇒ Object
Set the default ACL to acl.
See DRb::DRbServer.default_acl.
1891 1892 1893 |
# File 'lib/drb/drb.rb', line 1891 def install_acl(acl) DRbServer.default_acl(acl) end |
.install_id_conv(idconv) ⇒ Object
Set the default id conversion object.
This is expected to be an instance such as DRb::DRbIdConv that responds to #to_id and #to_obj that can convert objects to and from DRb references.
See DRbServer#default_id_conv.
1883 1884 1885 |
# File 'lib/drb/drb.rb', line 1883 def install_id_conv(idconv) DRbServer.default_id_conv(idconv) end |
.mutex ⇒ Object
:nodoc:
1897 1898 1899 |
# File 'lib/drb/drb.rb', line 1897 def mutex # :nodoc: @mutex end |
.primary_server ⇒ Object
The primary local dRuby server.
This is the server created by the #start_service call.
1779 1780 1781 |
# File 'lib/drb/drb.rb', line 1779 def primary_server @primary_server end |
.primary_server=(value) ⇒ Object
The primary local dRuby server.
This is the server created by the #start_service call.
1779 1780 1781 |
# File 'lib/drb/drb.rb', line 1779 def primary_server=(value) @primary_server = value end |
.regist_server(server) ⇒ Object
Registers server with DRb.
This is called when a new DRb::DRbServer is created.
If there is no primary server then server becomes the primary server.
Example:
require 'drb'
s = DRb::DRbServer.new # automatically calls regist_server
DRb.fetch_server s.uri #=> #<DRb::DRbServer:0x...>
1915 1916 1917 1918 1919 1920 |
# File 'lib/drb/drb.rb', line 1915 def regist_server(server) @server[server.uri] = server mutex.synchronize do @primary_server = server unless @primary_server end end |
.remove_server(server) ⇒ Object
Removes server from the list of registered servers.
1924 1925 1926 1927 1928 1929 1930 1931 |
# File 'lib/drb/drb.rb', line 1924 def remove_server(server) @server.delete(server.uri) mutex.synchronize do if @primary_server == server @primary_server = nil end end end |
.start_service(uri = nil, front = nil, config = nil) ⇒ Object
Start a dRuby server locally.
The new dRuby server will become the primary server, even if another server is currently the primary server.
uri is the URI for the server to bind to. If nil, the server will bind to random port on the default local host name and use the default dRuby protocol.
front is the server’s front object. This may be nil.
config is the configuration for the new server. This may be nil.
See DRbServer::new.
1771 1772 1773 |
# File 'lib/drb/drb.rb', line 1771 def start_service(uri=nil, front=nil, config=nil) @primary_server = DRbServer.new(uri, front, config) end |
.stop_service ⇒ Object
Stop the local dRuby server.
This operates on the primary server. If there is no primary server currently running, it is a noop.
1804 1805 1806 1807 |
# File 'lib/drb/drb.rb', line 1804 def stop_service @primary_server.stop_service if @primary_server @primary_server = nil end |
.thread ⇒ Object
Get the thread of the primary server.
This returns nil if there is no primary server. See #primary_server.
1872 1873 1874 |
# File 'lib/drb/drb.rb', line 1872 def thread @primary_server ? @primary_server.thread : nil end |
.to_id(obj) ⇒ Object
Get a reference id for an object using the current server.
This raises a DRbServerNotFound error if there is no current server. See #current_server.
1863 1864 1865 |
# File 'lib/drb/drb.rb', line 1863 def to_id(obj) current_server.to_id(obj) end |
.to_obj(ref) ⇒ Object
Convert a reference into an object using the current server.
This raises a DRbServerNotFound error if there is no current server. See #current_server.
1855 1856 1857 |
# File 'lib/drb/drb.rb', line 1855 def to_obj(ref) current_server.to_obj(ref) end |
.uri ⇒ Object
Get the URI defining the local dRuby space.
This is the URI of the current server. See #current_server.
1813 1814 1815 1816 1817 1818 1819 1820 1821 |
# File 'lib/drb/drb.rb', line 1813 def uri drb = Thread.current['DRb'] client = (drb && drb['client']) if client uri = client.uri return uri if uri end current_server.uri end |