class DCell::MailboxProxy

A proxy object for a mailbox that delivers messages to the real mailbox on a remote node on a server far, far away…

Public Class Methods

_load(address) click to toggle source

Loader for custom marshal format

# File lib/dcell/mailbox_proxy.rb, line 45
def self._load(address)
  if mailbox = DCell::Router.find(address)
    mailbox
  else
    DCell::MailboxProxy.new(address)
  end
end
new(address) click to toggle source
# File lib/dcell/mailbox_proxy.rb, line 7
def initialize(address)
  mailbox_id, node_id = address.split("@")

  # Create a proxy to the mailbox on the remote node
  raise ArgumentError, "no mailbox_id given" unless mailbox_id
 
  @node_id = node_id
  @node = Node[node_id]
  raise ArgumentError, "invalid node_id given" unless @node
  
  @mailbox_id = mailbox_id
end

Public Instance Methods

<<(message) click to toggle source

Send a message to the mailbox

# File lib/dcell/mailbox_proxy.rb, line 30
def <<(message)
  @node.async.send_message Message::Relay.new(self, message)
end
_dump(level) click to toggle source

Custom marshaller for compatibility with Celluloid::Mailbox marshalling

# File lib/dcell/mailbox_proxy.rb, line 40
def _dump(level)
  "#{@mailbox_id}@#{@node_id}"
end
address() click to toggle source

name@host style address

# File lib/dcell/mailbox_proxy.rb, line 21
def address
  "#{@mailbox_id}@#{@node_id}"
end
alive?() click to toggle source

Is the remote mailbox still alive?

# File lib/dcell/mailbox_proxy.rb, line 35
def alive?
  true # FIXME: hax!
end
inspect() click to toggle source
# File lib/dcell/mailbox_proxy.rb, line 25
def inspect
  "#<DCell::MailboxProxy:0x#{object_id.to_s(16)} #{address}>"
end