Fork me on GitHub

Talk to your cloud directly with ruberl

04 December 2008

Want to communicate with your cloud quickly?

Easy! First, download the gem ruberl

gem install auser-ruberl

Now you just have to set host and port and you can communicate with your gen_tcp server (or, in PoolParty’s case, the messenger) with either messenger_send! or messenger_cast! like so:

require "ruberl"

class Test < Ruberl::Base
end

@t = Test.new("75.101.162.232", 7050)
loop do
  nodes = @t.messenger_send!("get_current_nodes")  
  load = @t.messenger_send!("get_current_load cpu").to_f
  puts "Load on nodes #{nodes}: #{load}"
  sleep(10)
end

Alternatively, you can just set the attr_accessors host and port within your class and do the same thing, for instance

class Test < Ruberl::Base
 ... # some more methods
 def get_load
  @host = "host"
  @port = "port"
  messenger_send!("get_current_load cpu")
 end
 ...
end

Stay tuned for more quick tips, internals and discussions!