Class: EQ::Queueing::Queue
- Inherits:
-
Object
- Object
- EQ::Queueing::Queue
- Includes:
- Celluloid, Logging
- Defined in:
- lib/eq-queueing/queue.rb
Overview
this class basically provides a API that wraps the low-level calls to the queueing backend that is configured and passed to the #initialize method furthermore this class adds some functionality to serialize / deserialze using the Job class
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(queue_backend) ⇒ Queue
constructor
A new instance of Queue.
- #pop(job_id) ⇒ TrueClass, FalseClass
-
#push(*unserialized_payload) ⇒ Fixnum
Job_id.
-
#requeue_timed_out_jobs ⇒ Object
re-enqueues jobs that timed out.
-
#reserve ⇒ EQ::Job, nilClass
Job instance.
Methods included from Logging
Constructor Details
#initialize(queue_backend) ⇒ Queue
Returns a new instance of Queue.
19 20 21 |
# File 'lib/eq-queueing/queue.rb', line 19 def initialize queue_backend @queue = queue_backend end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
51 52 53 |
# File 'lib/eq-queueing/queue.rb', line 51 def queue @queue end |
Instance Method Details
#pop(job_id) ⇒ TrueClass, FalseClass
42 43 44 |
# File 'lib/eq-queueing/queue.rb', line 42 def pop job_id queue.pop job_id end |
#push(*unserialized_payload) ⇒ Fixnum
Returns job_id.
25 26 27 28 |
# File 'lib/eq-queueing/queue.rb', line 25 def push *unserialized_payload debug "enqueing #{unserialized_payload.inspect} ..." queue.push EQ::Job.dump(unserialized_payload) end |
#requeue_timed_out_jobs ⇒ Object
re-enqueues jobs that timed out
47 48 49 |
# File 'lib/eq-queueing/queue.rb', line 47 def requeue_timed_out_jobs queue.requeue_timed_out_jobs end |
#reserve ⇒ EQ::Job, nilClass
Returns job instance.
31 32 33 34 35 36 37 38 39 |
# File 'lib/eq-queueing/queue.rb', line 31 def reserve requeue_timed_out_jobs if serialized_job = queue.reserve job_id, serialized_payload = *serialized_job job = EQ::Job.load job_id, serialized_payload debug "dequeud #{job.inspect}" job end end |