Module: IronCuke::ScheduledQueue
- Included in:
- IronCuke
- Defined in:
- lib/iron_cuke/scheduled_queue.rb
Instance Method Summary collapse
- #cancel_schedule(scheduled_task_id) ⇒ Object
- #clear_schedules ⇒ Object
- #schedule(worker, schedule_options) ⇒ Object
- #schedules ⇒ Object
Instance Method Details
#cancel_schedule(scheduled_task_id) ⇒ Object
20 21 22 |
# File 'lib/iron_cuke/scheduled_queue.rb', line 20 def cancel_schedule(scheduled_task_id) scheduled_queue.each { |k,v| v.delete_if{ |data| data.id == scheduled_task_id } } end |
#clear_schedules ⇒ Object
24 25 26 |
# File 'lib/iron_cuke/scheduled_queue.rb', line 24 def clear_schedules scheduled_queue.clear end |
#schedule(worker, schedule_options) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/iron_cuke/scheduled_queue.rb', line 10 def schedule(worker, ) raise NotImplementedError if [:run_times] > 1 scheduled_queue[[:start_at]] ||= [] item = IronCuke::QueueItem.new(worker, ) scheduled_queue[[:start_at]] << item worker.schedule_id = item.id response = IronCuke::ScheduledQueue.create_response(item) end |
#schedules ⇒ Object
6 7 8 |
# File 'lib/iron_cuke/scheduled_queue.rb', line 6 def schedules scheduled_queue.values.map { |scheduled| scheduled.map { |data| data.worker } }.flatten end |