module DRb::DRbProtocol

Public Class Methods

add_protocol(prot) click to toggle source

Add a new protocol to the DRbProtocol module.

# File lib/drb/drb.rb, line 721
def add_protocol(prot)
  @protocol.push(prot)
end
open(uri, config, first=true) click to toggle source

Open a client connection to uri with the configuration config.

The DRbProtocol module asks each registered protocol in turn to try to open the URI. Each protocol signals that it does not handle that URI by raising a DRbBadScheme error. If no protocol recognises the URI, then a DRbBadURI error is raised. If a protocol accepts the URI, but an error occurs in opening it, a DRbConnError is raised.

# File lib/drb/drb.rb, line 733
def open(uri, config, first=true)
  @protocol.each do |prot|
    begin
      return prot.open(uri, config)
    rescue DRbBadScheme
    rescue DRbConnError
      raise($!)
    rescue
      raise(DRbConnError, "#{uri} - #{$!.inspect}")
    end
  end
  if first && (config[:auto_load] != false)
    auto_load(uri, config)
    return open(uri, config, false)
  end
  raise DRbBadURI, 'can\t parse uri:' + uri
end
open_server(uri, config, first=true) click to toggle source

Open a server listening for connections at uri with configuration config.

The DRbProtocol module asks each registered protocol in turn to try to open a server at the URI. Each protocol signals that it does not handle that URI by raising a DRbBadScheme error. If no protocol recognises the URI, then a DRbBadURI error is raised. If a protocol accepts the URI, but an error occurs in opening it, the underlying error is passed on to the caller.

# File lib/drb/drb.rb, line 761
def open_server(uri, config, first=true)
  @protocol.each do |prot|
    begin
      return prot.open_server(uri, config)
    rescue DRbBadScheme
    end
  end
  if first && (config[:auto_load] != false)
    auto_load(uri, config)
    return open_server(uri, config, false)
  end
  raise DRbBadURI, 'can\t parse uri:' + uri
end
uri_option(uri, config, first=true) click to toggle source

Parse uri into a [uri, option] pair.

The DRbProtocol module asks each registered protocol in turn to try to parse the URI. Each protocol signals that it does not handle that URI by raising a DRbBadScheme error. If no protocol recognises the URI, then a DRbBadURI error is raised.

# File lib/drb/drb.rb, line 782
def uri_option(uri, config, first=true)
  @protocol.each do |prot|
    begin
      uri, opt = prot.uri_option(uri, config)
      # opt = nil if opt == ''
      return uri, opt
    rescue DRbBadScheme
    end
  end
  if first && (config[:auto_load] != false)
    auto_load(uri, config)
    return uri_option(uri, config, false)
  end
  raise DRbBadURI, 'can\t parse uri:' + uri
end

Private Instance Methods

add_protocol(prot) click to toggle source

Add a new protocol to the DRbProtocol module.

# File lib/drb/drb.rb, line 721
def add_protocol(prot)
  @protocol.push(prot)
end
open(uri, config, first=true) click to toggle source

Open a client connection to uri with the configuration config.

The DRbProtocol module asks each registered protocol in turn to try to open the URI. Each protocol signals that it does not handle that URI by raising a DRbBadScheme error. If no protocol recognises the URI, then a DRbBadURI error is raised. If a protocol accepts the URI, but an error occurs in opening it, a DRbConnError is raised.

# File lib/drb/drb.rb, line 733
def open(uri, config, first=true)
  @protocol.each do |prot|
    begin
      return prot.open(uri, config)
    rescue DRbBadScheme
    rescue DRbConnError
      raise($!)
    rescue
      raise(DRbConnError, "#{uri} - #{$!.inspect}")
    end
  end
  if first && (config[:auto_load] != false)
    auto_load(uri, config)
    return open(uri, config, false)
  end
  raise DRbBadURI, 'can\t parse uri:' + uri
end
open_server(uri, config, first=true) click to toggle source

Open a server listening for connections at uri with configuration config.

The DRbProtocol module asks each registered protocol in turn to try to open a server at the URI. Each protocol signals that it does not handle that URI by raising a DRbBadScheme error. If no protocol recognises the URI, then a DRbBadURI error is raised. If a protocol accepts the URI, but an error occurs in opening it, the underlying error is passed on to the caller.

# File lib/drb/drb.rb, line 761
def open_server(uri, config, first=true)
  @protocol.each do |prot|
    begin
      return prot.open_server(uri, config)
    rescue DRbBadScheme
    end
  end
  if first && (config[:auto_load] != false)
    auto_load(uri, config)
    return open_server(uri, config, false)
  end
  raise DRbBadURI, 'can\t parse uri:' + uri
end
uri_option(uri, config, first=true) click to toggle source

Parse uri into a [uri, option] pair.

The DRbProtocol module asks each registered protocol in turn to try to parse the URI. Each protocol signals that it does not handle that URI by raising a DRbBadScheme error. If no protocol recognises the URI, then a DRbBadURI error is raised.

# File lib/drb/drb.rb, line 782
def uri_option(uri, config, first=true)
  @protocol.each do |prot|
    begin
      uri, opt = prot.uri_option(uri, config)
      # opt = nil if opt == ''
      return uri, opt
    rescue DRbBadScheme
    end
  end
  if first && (config[:auto_load] != false)
    auto_load(uri, config)
    return uri_option(uri, config, false)
  end
  raise DRbBadURI, 'can\t parse uri:' + uri
end