Class: RockQueue::ResqueQueue
- Inherits:
-
Object
- Object
- RockQueue::ResqueQueue
- Defined in:
- lib/rock-queue/adapters/resque.rb
Instance Attribute Summary collapse
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(options) ⇒ ResqueQueue
constructor
Contructor of Resque adapter.
-
#pop(queue) ⇒ Object
Retrieve item from Resque queue.
-
#push(queue, value, args) ⇒ Object
Push item from Resque queue.
-
#push_at(value, time_to_run_at, *args) ⇒ Object
Push items to Resque queue to be picked up by the worker on specified time.
- #queues ⇒ Object
-
#register_worker(worker) ⇒ Object
Register worker for web interface.
- #size(queue) ⇒ Object
Constructor Details
#initialize(options) ⇒ ResqueQueue
Contructor of Resque adapter
15 16 17 18 |
# File 'lib/rock-queue/adapters/resque.rb', line 15 def initialize() Resque.redis = "#{[:server]}:#{[:port]}" Resque.redis.sadd(:queues, :default) end |
Instance Attribute Details
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
12 13 14 |
# File 'lib/rock-queue/adapters/resque.rb', line 12 def obj @obj end |
Instance Method Details
#clear ⇒ Object
53 54 55 56 |
# File 'lib/rock-queue/adapters/resque.rb', line 53 def clear Resque.redis.flushall Resque.redis.sadd(:queues, :default) end |
#pop(queue) ⇒ Object
Retrieve item from Resque queue
43 44 45 46 |
# File 'lib/rock-queue/adapters/resque.rb', line 43 def pop(queue) job = Resque.reserve(queue) [job.payload_class, job.args] if job end |
#push(queue, value, args) ⇒ Object
Push item from Resque queue
21 22 23 24 25 26 27 28 |
# File 'lib/rock-queue/adapters/resque.rb', line 21 def push(queue, value, args) if !defined?(value.queue) value.class_eval do @queue = queue end end Resque.enqueue value, args end |
#push_at(value, time_to_run_at, *args) ⇒ Object
Push items to Resque queue to be picked up by the worker on specified time
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rock-queue/adapters/resque.rb', line 31 def push_at(value, time_to_run_at, *args) if !defined?(value.queue) value.class_eval do @queue = :default end end raise "resque_scheduler is required" unless Resque.respond_to?(:enqueue_at) Resque.enqueue_at time_to_run_at, value, args end |
#queues ⇒ Object
62 63 64 |
# File 'lib/rock-queue/adapters/resque.rb', line 62 def queues Resque.queues.sort.map(&:to_sym) end |
#register_worker(worker) ⇒ Object
Register worker for web interface
49 50 51 |
# File 'lib/rock-queue/adapters/resque.rb', line 49 def register_worker(worker) Resque.redis.sadd(:workers, worker) end |
#size(queue) ⇒ Object
58 59 60 |
# File 'lib/rock-queue/adapters/resque.rb', line 58 def size(queue) Resque.size(queue) end |