Class: DCell::RPC
- Inherits:
-
Celluloid::SyncCall
- Object
- Celluloid::SyncCall
- DCell::RPC
- Defined in:
- lib/dcell/rpc.rb
Defined Under Namespace
Classes: Manager
Class Method Summary collapse
-
._load(string) ⇒ Object
Loader for custom marshal format.
Instance Method Summary collapse
-
#_dump(level) ⇒ Object
Custom marshaller for compatibility with Celluloid::Mailbox marshalling.
-
#initialize(id, caller, method, arguments, block) ⇒ RPC
constructor
A new instance of RPC.
Constructor Details
#initialize(id, caller, method, arguments, block) ⇒ RPC
Returns a new instance of RPC.
7 8 9 |
# File 'lib/dcell/rpc.rb', line 7 def initialize(id, caller, method, arguments, block) @id, @caller, @method, @arguments, @block = id, caller, method, arguments, block end |
Class Method Details
._load(string) ⇒ Object
Loader for custom marshal format
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dcell/rpc.rb', line 18 def self._load(string) id = string.slice!(0, string.index(":") + 1) match = id.match(/^([0-9a-fA-F]+)@(.+?):$/) raise ArgumentError, "couldn't parse call ID" unless match call_id, node_id = match[1], match[2] if DCell.id == node_id Manager.claim Integer("0x#{call_id}") else caller, method, arguments, block = Marshal.load(string) RPC.new("#{call_id}@#{node_id}", caller, method, arguments, block) end end |
Instance Method Details
#_dump(level) ⇒ Object
Custom marshaller for compatibility with Celluloid::Mailbox marshalling
12 13 14 15 |
# File 'lib/dcell/rpc.rb', line 12 def _dump(level) payload = Marshal.dump [@caller, @method, @arguments, @block] "#{@id}:#{payload}" end |