module DRb

def config

See #current_server and DRbServer::make_config.
If there is no current server, this returns the default configuration.

Get the configuration of the current server.
def config
  current_server.config
rescue
  DRbServer.make_config
end

def current_server

error is raised.
If the above rule fails to find a server, a DRbServerNotFound

the primary server.
server is that server. Otherwise, the current server is
call on the server or one of its objects), the current
thread of a dRuby server (typically, as a result of a remote
In the context of execution taking place within the main

Get the 'current' server.
def current_server
  drb = Thread.current['DRb']
  server = (drb && drb['server']) ? drb['server'] : @primary_server
  raise DRbServerNotFound unless server
  return server
end

def fetch_server(uri)

See also regist_server and remove_server.

Retrieves the server with the given +uri+.
def fetch_server(uri)
  @server[uri]
end

def front

See #current_server.
This raises a DRbServerNotFound error if there is no current server.

Get the front object of the current server.
def front
  current_server.front
end

def here?(uri)

Is +uri+ the URI for the current local server?
def here?(uri)
  current_server.here?(uri) rescue false
  # (current_server.uri rescue nil) == uri
end

def install_acl(acl)

See DRb::DRbServer.default_acl.

Set the default ACL to +acl+.
def install_acl(acl)
  DRbServer.default_acl(acl)
end

def install_id_conv(idconv)

See DRbServer#default_id_conv.

#to_id and #to_obj that can convert objects to and from DRb references.
This is expected to be an instance such as DRb::DRbIdConv that responds to

Set the default id conversion object.
def install_id_conv(idconv)
  DRbServer.default_id_conv(idconv)
end

def mutex # :nodoc:

:nodoc:
def mutex # :nodoc:
  @mutex
end

def regist_server(server)

DRb.fetch_server s.uri #=> #
s = DRb::DRbServer.new # automatically calls regist_server

require 'drb'

Example:

If there is no primary server then +server+ becomes the primary server.

This is called when a new DRb::DRbServer is created.

Registers +server+ with DRb.
def regist_server(server)
  @server[server.uri] = server
  mutex.synchronize do
    @primary_server = server unless @primary_server
  end
end

def remove_server(server)

Removes +server+ from the list of registered servers.
def remove_server(server)
  @server.delete(server.uri)
  mutex.synchronize do
    if @primary_server == server
      @primary_server = nil
    end
  end
end

def start_service(uri=nil, front=nil, config=nil)

See DRbServer::new.

be nil.
+config+ is the configuration for the new server. This may

+front+ is the server's front object. This may be nil.

name and use the default dRuby protocol.
the server will bind to random port on the default local host
+uri+ is the URI for the server to bind to. If nil,

if another server is currently the primary server.
The new dRuby server will become the primary server, even

Start a dRuby server locally.
def start_service(uri=nil, front=nil, config=nil)
  @primary_server = DRbServer.new(uri, front, config)
end

def stop_service

server currently running, it is a noop.
This operates on the primary server. If there is no primary

Stop the local dRuby server.
def stop_service
  @primary_server.stop_service if @primary_server
  @primary_server = nil
end

def thread

This returns nil if there is no primary server. See #primary_server.

Get the thread of the primary server.
def thread
  @primary_server ? @primary_server.thread : nil
end

def to_id(obj)

See #current_server.
This raises a DRbServerNotFound error if there is no current server.

Get a reference id for an object using the current server.
def to_id(obj)
  current_server.to_id(obj)
end

def to_obj(ref)

See #current_server.
This raises a DRbServerNotFound error if there is no current server.

Convert a reference into an object using the current server.
def to_obj(ref)
  current_server.to_obj(ref)
end

def uri

This is the URI of the current server. See #current_server.

Get the URI defining the local dRuby space.
def uri
  drb = Thread.current['DRb']
  client = (drb && drb['client'])
  if client
    uri = client.uri
    return uri if uri
  end
  current_server.uri
end