Class: SolidQueue::Scheduler::RecurringSchedule
- Inherits:
-
Object
- Object
- SolidQueue::Scheduler::RecurringSchedule
show all
- Includes:
- AppExecutor
- Defined in:
- lib/solid_queue/scheduler/recurring_schedule.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#handle_thread_error, #wrap_in_app_executor
Constructor Details
Returns a new instance of RecurringSchedule.
9
10
11
12
|
# File 'lib/solid_queue/scheduler/recurring_schedule.rb', line 9
def initialize(tasks)
@configured_tasks = Array(tasks).map { |task| SolidQueue::RecurringTask.wrap(task) }.select(&:valid?)
@scheduled_tasks = Concurrent::Hash.new
end
|
Instance Attribute Details
Returns the value of attribute configured_tasks.
7
8
9
|
# File 'lib/solid_queue/scheduler/recurring_schedule.rb', line 7
def configured_tasks
@configured_tasks
end
|
#scheduled_tasks ⇒ Object
Returns the value of attribute scheduled_tasks.
7
8
9
|
# File 'lib/solid_queue/scheduler/recurring_schedule.rb', line 7
def scheduled_tasks
@scheduled_tasks
end
|
Instance Method Details
#empty? ⇒ Boolean
14
15
16
|
# File 'lib/solid_queue/scheduler/recurring_schedule.rb', line 14
def empty?
configured_tasks.empty?
end
|
#schedule_task(task) ⇒ Object
29
30
31
|
# File 'lib/solid_queue/scheduler/recurring_schedule.rb', line 29
def schedule_task(task)
scheduled_tasks[task.key] = schedule(task)
end
|
#schedule_tasks ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/solid_queue/scheduler/recurring_schedule.rb', line 18
def schedule_tasks
wrap_in_app_executor do
persist_tasks
reload_tasks
end
configured_tasks.each do |task|
schedule_task(task)
end
end
|
#task_keys ⇒ Object
38
39
40
|
# File 'lib/solid_queue/scheduler/recurring_schedule.rb', line 38
def task_keys
configured_tasks.map(&:key)
end
|
#unschedule_tasks ⇒ Object
33
34
35
36
|
# File 'lib/solid_queue/scheduler/recurring_schedule.rb', line 33
def unschedule_tasks
scheduled_tasks.values.each(&:cancel)
scheduled_tasks.clear
end
|