Class: EQ::Queueing::Queue
- Inherits:
-
Object
- Object
- EQ::Queueing::Queue
show all
- Extended by:
- SingleForwardable
- 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 Method Summary
collapse
Methods included from Logging
#debug, #info, #log_error
Constructor Details
#initialize(queue_backend) ⇒ Queue
Returns a new instance of Queue.
14
15
16
|
# File 'lib/eq-queueing/queue.rb', line 14
def initialize queue_backend
@queue = queue_backend
end
|
Instance Method Details
#clear ⇒ Object
52
53
54
|
# File 'lib/eq-queueing/queue.rb', line 52
def clear
queue.clear
end
|
#count(name = nil) ⇒ Object
46
|
# File 'lib/eq-queueing/queue.rb', line 46
def count name=nil; queue.count name; end
|
#iterator(&block) ⇒ Object
48
49
50
|
# File 'lib/eq-queueing/queue.rb', line 48
def iterator &block
queue.iterator &block
end
|
#jobs ⇒ Object
43
|
# File 'lib/eq-queueing/queue.rb', line 43
def jobs; queue.jobs; end
|
#pop(*args) ⇒ Object
TODO #pop method: shall we add a check, when the job is worked on, if we are the worker?
37
38
39
|
# File 'lib/eq-queueing/queue.rb', line 37
def pop *args
queue.pop *args
end
|
#push(job_class, *job_payload) ⇒ Fixnum
20
21
22
23
|
# File 'lib/eq-queueing/queue.rb', line 20
def push job_class, *job_payload
debug "enqueing #{job_payload.inspect} ..."
queue.push EQ::Job.new(nil, job_class, job_payload)
end
|
#requeue_timed_out_jobs ⇒ Object
41
|
# File 'lib/eq-queueing/queue.rb', line 41
def requeue_timed_out_jobs; queue.requeue_timed_out_jobs; end
|
#reserve ⇒ EQ::Job, nilClass
26
27
28
29
30
31
32
|
# File 'lib/eq-queueing/queue.rb', line 26
def reserve
requeue_timed_out_jobs
if job = queue.reserve
debug "dequeud #{job.inspect}"
job
end
end
|
#waiting ⇒ Object
45
|
# File 'lib/eq-queueing/queue.rb', line 45
def waiting; queue.waiting; end
|
#working ⇒ Object
44
|
# File 'lib/eq-queueing/queue.rb', line 44
def working; queue.working; end
|