Sha256: 238374635533cd0e221aee1caa218c6f2278e98a9cf3fd5635a0b9d1c591caa8

Contents?: true

Size: 638 Bytes

Versions: 2

Compression:

Stored size: 638 Bytes

Contents

require 'rubygems'
#require 'gearman'
require '../lib/gearman'

Gearman::Util.debug = true

servers = ['localhost:4730', 'localhost:4731']
w = Gearman::Worker.new(servers)

ability_name_with_prefix = Gearman::Util.ability_name_with_prefix("test","sleep")

# Add a handler for a "sleep" function that takes a single argument, the
# number of seconds to sleep before reporting success.
w.add_ability(ability_name_with_prefix) do |data,job|
 seconds = data
 (1..seconds.to_i).each do |i|
   sleep 1
   print i
   # Report our progress to the job server every second.
   job.report_status(i, seconds)
 end
 # Report success.
 true
end
w.work

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
evented-gearman-ruby-1.0.0 examples/worker_prefix.rb
gearman-ruby-2.0.0 examples/worker_prefix.rb