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
» darachennis (darachennis): RT @JackassFanboy: Jackass Alert - Programming language jackass-of-the-week re-invents Erlang history. http://bit.ly/9Q8yQg #erlang:... http://bit.ly/dbZGfD
» JackassFanboy (Jackass Fanboy): Jackass Alert - Programming language jackass-of-the-week re-invents Erlang history. http://bit.ly/9Q8yQg #erlang:... http://bit.ly/dbZGfD
» grempe (Glenn Rempe): Programming language jackass-of-the-week re-invents Erlang history. http://bit.ly/9Q8yQg #erlang
» aberfoyle (aberfoyle): RT @FrancescoC: How did #Scala influence #Erlang? http://bit.ly/cR5YrD Too funny! -> the comments are even better :)
» fprogblogs (ФП-Блоги): notacodemonkey пишет: Erlang/OTP / Ускоряем работу Erlang системы без замедления разработки http://bit.ly/9dXcjo
» fprogblogs (ФП-Блоги): zabivator пишет: Erlang + cygwin => troubles http://bit.ly/b9qPNl
» fprogblogs (ФП-Блоги): zabivator пишет: Erlang + crypto module http://bit.ly/bgGsso
» fprogblogs (ФП-Блоги): Dmitry Vasiliev пишет: Продолжаем знакомится с Erlang - новая статья http://bit.ly/answzX
» fprogblogs (ФП-Блоги): zabivator пишет: Erlang + mochiweb + erlang_rfc4627 http://bit.ly/d3jY5M
» fprogblogs (ФП-Блоги): Dmitry Vasiliev пишет: Пишем первые модули на Erlang http://bit.ly/a1Gtqz
Statistics
Number of aggregated posts: 9908
Number of comments: 379
Most recent article: March 07, 2010
Latest comments
» Jeff Martens on It Made Sense in 1978: I agree that word size is machine specific, but it becomes language-specific once it’s in a language definition. In Java an …
» Adley on XP Day Suisse 2009: What a great post. What an inspiration for everyone who is asking ‘Where is all this stuff I’ve asked for?’ and …
» Adley Fair on CouchDB Load Balancing and Replication using HAProxy.: You’re really thankful for this post, I’ve been really enjoying checking up your posts from time to time. Looking forward to …