rinterface: a pure Ruby client to talk to Erlang

May 20, 2009

After 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:

  1. The Erlang node and Ruby client must be running on the same machine. This will not be hard to change
  2. 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

Connecting to Erlang’s epmd from Ruby

April 24, 2009

Deprec, Ubuntu 7.0.4 (Feisty), and your Proxy server

September 05, 2007

Create a ShapeFile with Ruby

August 20, 2007

Scrape the Wayback machine with this little script

August 17, 2007

Modify the XML output from your Model

August 16, 2007

Ruby OCI8 Library Unsupported Datatypes

April 17, 2007

Mongrel based Gem Server

March 15, 2007

What is defined?

March 01, 2007

RAILS_DEFAULT_LOGGER

February 27, 2007