Class: Jobs::TopicTimerEnqueuer

Inherits:
Scheduled show all
Defined in:
app/jobs/scheduled/topic_timer_enqueuer.rb

Overview

Runs periodically to look through topic timers that are ready to execute, and enqueues their related jobs.

Any leftovers will be caught in the next run, because execute_at will be < now, and topic timers that have run are deleted on completion or otherwise have their execute_at time modified.

Instance Method Summary collapse

Methods inherited from Scheduled

#perform

Methods inherited from Base

acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately

Instance Method Details

#execute(_args = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/jobs/scheduled/topic_timer_enqueuer.rb', line 13

def execute(_args = nil)
  TopicTimer.pending_timers.find_each do |timer|
    # the typed job may not enqueue if it has already
    # been scheduled with enqueue_at
    begin
      timer.enqueue_typed_job
    rescue => err
      Discourse.warn_exception(
        err,
        message: "Error when attempting to enqueue topic timer job for timer #{timer.id}",
      )
    end
  end
end