Method: Worker::Queue#initialize
- Defined in:
- lib/worker/queue.rb
#initialize(opts = {}) ⇒ Queue
Returns a new instance of Queue.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/worker/queue.rb', line 10 def initialize(opts={}) @logger = Logger.new(STDOUT) db_config = opts[:db_config] || Worker.db db_config.merge(logger: logger) if opts[:log_queries] @db = Sequel.connect(db_config) name = `hostname`.chomp("\n") @id = "#{name}.#{Process.pid}.#{rand(0..1000)}-#{opts[:queue_name] || 'all'}" @jobs_per_worker = opts[:jobs_per_worker] || 5 @max_job_time = opts[:max_job_time] || 5 * 60 # in seconds @queue_name = opts[:queue_name] @max_attempts = opts[:max_attempts] || 20 @poll_interval = opts[:poll_interval] || 5 # 5 second polling @log_backtrace = !!opts[:log_backtrace] create_table end |