rinterface: a pure Ruby client to talk to Erlang
Dave Bryson - daveb - May 21, 2009After digging through the jinterface code for the past couple of evenings I finally have a working Ruby client that can make RPC calls to an Erlang node. Although the code is a bit rough right now, it works.
I’m hoping to evolve it into a full Ruby node with capabilities similar to jinterface (the java implementation included with the Erlang).
The current implementation has a few limitations:
- The Erlang node and Ruby client must be running on the same machine. This will not be hard to change
- The Erlang process must have a registered name
Essentially right now it works a lot like the native rpc:call in Erlang.
Here’s an example of a Ruby client calling a Erlang process called ‘math’:
EM.run do
# Connect to epmd to get the port of 'math'.
# 'math' is the -sname of the erlang node
epmd = EpmdConnection.lookup_node("math")
epmd.callback do |port|
puts "got the port #{port}"
# make the rpc call to 'math' on port for
# mod 'math_server' on fun 'add' with args
node = Node.rpc_call("math",port.to_i,
"math_server",
"add",[10,20])
node.callback{ |result|
puts "Sum is: #{result}"
EM.stop
}
node.errback{ |err|
puts "Error: #{err}"
EM.stop
}
end
epmd.errback do |err|
puts "Error: #{err}"
EM.stop
end
end
You can check out the code here: rinterface
Categories: Blogs Dave Bryson
Comments
No comments so far, you could be the first.Add comment
Erlang on Twitter
» fedorausers (Fedora Linux Users): #linux #fedora Re: erlang-doc - dubious dependencies http://dlvr.it/4cWnw
» bestform (bestform): @danielefrijia lisp und erlang habe ich beides schon beruflich eingesetzt.
» bestform (bestform): Es gibt übrigens durchaus Antworten, die ich akzeptieren würde. Lisp, Erlang, Clojure, von mir aus auch Scala. Na? Wie sieht’s aus? :)
» charpi (Nicolas Charpentier): RT @pavlobaron: Even if #erlang hasn’t been mentioned in the latest #thoughtworks report, it won’t keep us from building real cool things with it
» chrisumbel (chris umbel): the functional work i’ve done in the last 18 months (erlang & clojure) have clearly changed how i write Java & .Net code 4 the good
» grzegorzkazulak (Grzegorz Kazulak): @strzalekk erlang? nice :)
» aprimc (Andrej Primc): Reinventing the wheel. No agreeable template engine in Erlang.
» fedorausers (Fedora Linux Users): #linux #fedora erlang-doc - dubious dependencies http://dlvr.it/4cNwW
» opencrowd (OpenCrowd): Cloudant’s BigCouch is open-source. BigCouch is a set of Erlang/OTP applications for creating a cluster of CouchDBs http://bit.ly/bILJ8p
» Missing_Faktor (Rahul Goma Phulore): RT @pavlobaron: Even if #erlang hasn’t been mentioned in the latest #thoughtworks report, it won’t keep us from building real cool things with it
Statistics
Number of aggregated posts: 10079
Number of comments: 554
Most recent article: September 01, 2010
Latest comments
» Nissan Frontier Superchager on Erlang Doesn’t Fit The JVM: I don’t believe it is the silver bullet that fixes all the problems that required you to do your JVM tuning….Nissan Frontier Superchager
» Nissan Frontier Superchager on What to do About Erlang's Records?: The general solution is to delete all the keys that should have new values, then insert the new key/value pairs…
» videomob on Java And Threads (Jetty): Хватит спамить, накинулись