Class: Backburner::Workers::Simple

Inherits:
Backburner::Worker show all
Defined in:
lib/backburner/workers/simple.rb

Instance Attribute Summary

Attributes inherited from Backburner::Worker

#connection, #tube_names

Instance Method Summary collapse

Methods inherited from Backburner::Worker

enqueue, #handle_failure_for_job, #initialize, #process_tube_names, #shutdown, start, #work_one_job

Methods included from Logger

included, #job_started_at, #log_error, #log_info, #log_job_begin, #log_job_end, #logger

Methods included from Helpers

#classify, #constantize, #dasherize, #exception_message, #expand_tube_name, included, #queue_config, #resolve_max_job_retries, #resolve_priority, #resolve_respond_timeout, #resolve_retry_delay, #resolve_retry_delay_proc

Constructor Details

This class inherits a constructor from Backburner::Worker

Instance Method Details

#prepareObject

Used to prepare job queues before processing jobs. Setup beanstalk tube_names and watch all specified tubes for jobs.

Examples:

@worker.prepare

Raises:

  • (Beaneater::NotConnected)

    If beanstalk fails to connect.



11
12
13
14
15
# File 'lib/backburner/workers/simple.rb', line 11

def prepare
  self.tube_names.map! { |name| expand_tube_name(name)  }.uniq!
  log_info "Working #{tube_names.size} queues: [ #{tube_names.join(', ')} ]"
#        self.connection.tubes.watch!(*self.tube_names)
end

#startObject

Starts processing new jobs indefinitely. Primary way to consume and process jobs in specified tubes.

Examples:

@worker.start


23
24
25
26
# File 'lib/backburner/workers/simple.rb', line 23

def start
  prepare
  loop { work_one_job }
end