Class: JobQueue
- Inherits:
-
Object
- Object
- JobQueue
- Defined in:
- lib/job_queue/job_queue.rb
Overview
JobQueue abstracts the task of adding work to a queue.
Beanstalk is fantastic, but maybe not “enterprise grade”.
AMQP is fantastic, but it’s bloody complex and has to run inside an eventmachine loop.
Take your pick!
Before use, an adapter must be chosen:
JobQueue.adapter = JobQueue::BeanstalkAdapter.new
Jobs can then be simply added to the queue with
JobQueue.put("flubble bubble")
Defined Under Namespace
Classes: AMQPAdapter, BeanstalkAdapter, TestAdapter, VerboseAdapter
Class Attribute Summary collapse
-
.adapter ⇒ Object
Returns the value of attribute adapter.
-
.logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
Class Attribute Details
.adapter ⇒ Object
Returns the value of attribute adapter.
20 21 22 |
# File 'lib/job_queue/job_queue.rb', line 20 def adapter @adapter end |
.logger ⇒ Object
Returns the value of attribute logger.
21 22 23 |
# File 'lib/job_queue/job_queue.rb', line 21 def logger @logger end |
Class Method Details
.put(string) ⇒ Object
33 34 35 |
# File 'lib/job_queue/job_queue.rb', line 33 def self.put(string) adapter.put(string) end |
.subscribe(error_report = nil, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/job_queue/job_queue.rb', line 37 def self.subscribe(error_report = nil, &block) catch :stop do error_report ||= Proc.new do |job, e| JobQueue.logger.error \ "Job failed\n" \ "==========\n" \ "Job content: #{job.inspect}\n" \ "Exception: #{e.}\n" \ "#{e.backtrace.join("\n")}\n" \ "\n" end adapter.subscribe(error_report, &block) end end |