Module: IronCuke::Queue
- Included in:
- IronCuke
- Defined in:
- lib/iron_cuke/queue.rb
Instance Method Summary collapse
Instance Method Details
#clear_queue ⇒ Object
26 27 28 |
# File 'lib/iron_cuke/queue.rb', line 26 def clear_queue worker_queue.clear end |
#queue(worker, options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/iron_cuke/queue.rb', line 15 def queue(worker, ) = {:priority => 0}.merge() raise NotImplementedError unless [:priority].between?(0,2) worker_queue[[:priority]] ||= [] item = IronCuke::QueueItem.new(worker, ) worker_queue[[:priority]] << item worker.task_id = item.id response = IronCuke::Queue.create_response(item) end |
#queued(priority = 0) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/iron_cuke/queue.rb', line 6 def queued(priority = 0) raise ArgumentError unless priority.between?(0,2) worker_queue.select{|p, workers| p >= priority}.values.map { |p| p.map { |data| data.worker } }.flatten end |