Class: DCell::MailboxProxy
- Inherits:
-
Object
- Object
- DCell::MailboxProxy
- Defined in:
- lib/dcell/mailbox_proxy.rb
Overview
A proxy object for a mailbox that delivers messages to the real mailbox on a remote node on a server far, far away…
Defined Under Namespace
Classes: InvalidNodeError
Class Method Summary collapse
-
._load(address) ⇒ Object
Loader for custom marshal format.
Instance Method Summary collapse
-
#<<(message) ⇒ Object
Send a message to the mailbox.
-
#_dump(level) ⇒ Object
Custom marshaller for compatibility with Celluloid::Mailbox marshalling.
-
#address ⇒ Object
name@host style address.
-
#alive? ⇒ Boolean
Is the remote mailbox still alive?.
-
#initialize(address) ⇒ MailboxProxy
constructor
A new instance of MailboxProxy.
- #inspect ⇒ Object
Constructor Details
#initialize(address) ⇒ MailboxProxy
Returns a new instance of MailboxProxy.
7 8 9 10 11 12 13 14 15 16 17 18 |
# 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 |
Class Method Details
Instance Method Details
#<<(message) ⇒ Object
Send a message to the mailbox
30 31 32 |
# File 'lib/dcell/mailbox_proxy.rb', line 30 def <<() @node.async. Message::Relay.new(self, ) end |
#_dump(level) ⇒ Object
Custom marshaller for compatibility with Celluloid::Mailbox marshalling
40 41 42 |
# File 'lib/dcell/mailbox_proxy.rb', line 40 def _dump(level) "#{@mailbox_id}@#{@node_id}" end |
#address ⇒ Object
name@host style address
21 22 23 |
# File 'lib/dcell/mailbox_proxy.rb', line 21 def address "#{@mailbox_id}@#{@node_id}" end |
#alive? ⇒ Boolean
Is the remote mailbox still alive?
35 36 37 |
# File 'lib/dcell/mailbox_proxy.rb', line 35 def alive? true # FIXME: hax! end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/dcell/mailbox_proxy.rb', line 25 def inspect "#<DCell::MailboxProxy:0x#{object_id.to_s(16)} #{address}>" end |