class DCell::RPC

Public Class Methods

_load(string) click to toggle source

Loader for custom marshal format

# File lib/dcell/rpc.rb, line 40
def self._load(string)
  id = string.slice!(0, string.index(":") + 1)
  match = id.match(/^([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})@(.+?):$/)
  raise ArgumentError, "couldn't parse call ID" unless match

  uuid, node_id = match[1], match[2]

  if DCell.id == node_id
    Manager.claim uuid
  else
    type = string.slice!(0, string.index(":") + 1)
    types = {
      "rpc" => RPC,
      "rpb" => RPB,
      "rpbc" => RPBC,
    }
    types.fetch(type[0..-2]).new("#{uuid}@#{node_id}", *Marshal.load(string))
  end
end
new(id, sender, method, arguments, block) click to toggle source
# File lib/dcell/rpc.rb, line 29
def initialize(id, sender, method, arguments, block)
  @id, @sender, @method, @arguments, @block = id, sender, method, arguments, block
end

Public Instance Methods

_dump(level) click to toggle source

Custom marshaller for compatibility with Celluloid::Mailbox marshalling

# File lib/dcell/rpc.rb, line 34
def _dump(level)
  payload = Marshal.dump [@sender, @method, @arguments, @block]
  "#{@id}:rpc:#{payload}"
end