Class: Erlang::Node
- Inherits:
-
Object
- Object
- Erlang::Node
- Defined in:
- lib/rinterface/node.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
- #do_connect(node, mod, fun, args) ⇒ Object
-
#initialize ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
11 12 13 |
# File 'lib/rinterface/node.rb', line 11 def initialize @result = nil end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
9 10 11 |
# File 'lib/rinterface/node.rb', line 9 def result @result end |
Class Method Details
.fun(node, mod, fun, *args) ⇒ Object
16 17 18 |
# File 'lib/rinterface/node.rb', line 16 def fun(node, mod, fun, *args) rpc(node, mod, fun, args) end |
.rpc(node, mod, fun, args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rinterface/node.rb', line 20 def rpc(node, mod, fun, args) n = self.new setup = proc{ n.do_connect(node, mod, fun, args) } if EM.reactor_running? setup.call else EM.run(&setup) end n.result end |
Instance Method Details
#do_connect(node, mod, fun, args) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rinterface/node.rb', line 34 def do_connect(node,mod,fun,args) epmd = EpmdConnection.lookup_node(node) epmd.callback do |port| conn = NodeConnection.rpc_call(node,port,mod,fun,args) do |c| c.destnode = node c.mod = mod c.fun = fun c.args = args c.port = port c.myname = build_nodename c. = end conn.callback do |r| # Check for bad rpc response # this is where I miss the patten matching in Erlang if r.is_a?(Array) if !r.empty? && r[0] == :badrpc @result = [:badrpc,r[1]] else @result = [:ok,r] end else @result = [:ok,r] end EM.stop end conn.errback do |err| # never called?? @result = [:badrpc,err] EM.stop end end epmd.errback do |err| # return bad RPC no port found (0) @result = [:badrpc,"no port found for service"] EM.stop end end |