dgreceanu of The Code Killers
5/23/2014 - 12:30 PM

Ruby Gearman Worker

Ruby Gearman Worker

#!/usr/bin/env ruby

require 'rubygems'
require 'gearman'
require 'json'

w = Gearman::Worker.new(['***.***.***.***:4730'])

w.add_ability('aduna11') do |data,job|
  puts "Lucrez: #{job.handle()}"
  Hash["lucrator" => "ruby-laptop", "rezultat" => data.to_i + 11].to_json
end

loop { w.work }