Sha256: 5ab67afeea1d75a61235554b910dfb96d60ad166e73529155de29f2a7636ecf2

Contents?: true

Size: 564 Bytes

Versions: 2

Compression:

Stored size: 564 Bytes

Contents

require 'simpleworker'

tasks = ['first', 'second', 'third']
redis = Redis.new
runner = SimpleWorker::Runner.new(redis, tasks,
                                  :max_retries => 2)

worker_thread = Thread.new do
  task_queue = SimpleWorker::TaskQueue.new(redis, 'my_hostname', runner.jobid)

  task_queue.fire_start

  task_queue.each_task do |task|
    if task == 'first'
      sleep 15
    elsif task == 'second'
      task_queue.expire_current_task
    else
      task_queue.fire_log_message "Task: #{task}"
    end
  end

  task_queue.fire_stop
end

runner.run

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simpleworker-0.1.1 examples/basic.rb
simpleworker-0.1.0 examples/basic.rb